问题描述:

I am using CakePHP and the FormHelper to generate my form.

However, I need to create a markup similar to the following structure:

(radio1) [TEXT_INPUT] or more credits

(radio2) No Limit

Now, I am not sure how to approach this, but logically I would imagine it to be something like:

$options = array(

'oneormore' => $this->Form->input( 'text_for_oneormore' ) . ' or more credits',

'nolimit' => 'No Limit'

);

echo $this->Html->radio( 'quantity', $options, array() );

Does anyone have any ideas they can offer? I am stumped on this issue.

网友答案:

One way would be to use the 'before' and 'after' options which append the string you put in there. I think you can get away with entire fields there.

http://book.cakephp.org/view/1393/options-before-options-between-options-separator-a

Another way would be to make your own helper based on the FormHelper.

网友答案:

I may be a bit late to the show, but I came across this issue in upgrading a site to cakephp 2.x. I found if I use the "'hiddenField' => false" option, I was able the separate the radio buttons and put text or select inputs between them:

Your question relates to which of the following:<br>
<?php 
  echo $this->Form->radio("qOption", array('0' => 'Find a store'), array("label" => false, 'hiddenField' => false));
  echo $this->Form->radio("qOption", array('2' => 'Choose a Product'), array("label" => false, 'hiddenField' => false));
  echo $this->Form->select('product', $products, array());
  echo $this->Form->radio("qOption", array('1' => 'Other'), array("label" => false, 'hiddenField' => false));
  echo $this->Form->input("other", array("class"=>"f_12_darkgray", "size"=>"40", 'div' => false, "label" => false)); 
?>
相关阅读:
Top