How to build radio buttons horizontally, but not vertically?

I watched the Cookbook - 7.3.3 Automagic Form Elements , trying to find a way for the radio buttons to align horizontally than vertically. I looked at the 'div' => 'class_name' $optionswell $options[‘between’], $options[‘separator’]and $options[‘after’], but did not succeed. Is there a way to “cake” to do this?

<?=$form->input('Product Type', array(
     'type' => 'radio',
     'id' => $tire['ProductType']['id'],
     'name' => $tire['ProductType']['id'],
     'options' => array(2=>'Tire Manufacturer', 7=>'Rim Manufacturer '),
));?>

Equivalent to this

<label>Product Type</label>
<div style="padding-top:5px;">
    <input type="radio" name="data[Manufacturer][product_type_id]" value="<?=$tire['ProductType']['id']?>"> Tire Manufacturer &nbsp;&nbsp;
    <input type="radio" name="data[Manufacturer][product_type_id]" value="<?=$wheel['ProductType']['id']?>"> Rim Manufacturer
</div>
+3
source share
6 answers

- "LI", CSS "UL", "LI" , . .

+2

: (viewfile.ctp):

<div>  
<?php  
echo $this->Form->create('changeRegion');  
$options=array('US'=>'U.S.','CA'=>'Canada', 'FN'=>'International');  
$attributes=array('legend'=>false, 'label'=>false, 'value'=>'US', 'class'=>'locRad');  
echo $form->radio('subLocation',$options,$attributes);  
echo $this->Form->end();  
?>  
<div class="clear"></div>  
</div>  

, 'label' = > false 'legend' = > false.

:

input[type=radio] {
float:left;
margin:0px;
width:20px;
}

form#changeRegionStdForm input[type=radio].locRad {
margin:3px 0px 0px 3px; 
float:none;
}

- CakePHP [type = radio] ( appro/css/cake.generic.css) . , , , , (form # changeRegionStdForm input [type = radio].locRad). #, [type =. [type =, .

, - .

+4

. , , .

- :

<ul id="hMenu"><li>
<?php
$attributes=array('legend'=>false, 'separator'=>'</li><li>', 'label'=>false);
$form->input('Product Type',$options, $attributes);
?>
</li></ul>

id hMenu. .

This without any style gives the right switches. But if you use css style on ul and li , you can literally make it stand on your head! :)

+2
source

use this:

$form->input('Product Type', array(
 'type' => 'radio',
 'id' => $tire['ProductType']['id'],
 'name' => $tire['ProductType']['id'],
 'options' => array(2=>'Tire Manufacturer', 7=>'Rim Manufacturer '),
 ***********************
 'seperator' => '<br />'
 ***********************
));

The result is as follows:

<label>Product Type</label>
<div style="padding-top:5px;">
  <input type="radio" name="data[Manufacturer][product_type_id]" value="<?=$tire['ProductType']['id']?>"> Tire Manufacturer &nbsp;&nbsp;
  <br />
  <input type="radio" name="data[Manufacturer][product_type_id]" value="<?=$wheel['ProductType']['id']?>"> Rim Manufacturer
</div>
+2
source

Try it, I got my code working through this.

<ul id = "navlist">
    <fieldset>
      <legend><?php echo __('Insert User'); ?></legend>

        <li><?php //echo $this->Form->input('Site', array('options' => $arraycharges));?></li>

        <li><?php echo $this->Form->input('MobileApp', array('options' => array('admin' => 'Admin', 'user' => 'User')));?></li>

        <li><?php echo $this->Form->input('Location', array('options' => array('admin' => 'Admin', 'user' => 'User')));?></li>

    <li><?php echo $this->Form->end(__('GO')); ?></li>

    </fieldset>
 </ul>

in the stylesheet add the following.

#navlist li {
    display: inline-block;
    list-style-type: none;
    padding-right: 20px;
}
+2
source

You follow as follows:

<ul>
<li style="width: 200px;float: left;list-style: none">
    <?php
    $attributes=array(
        'legend'=>false,
        'after'=>'</li>',
        'separator'=>'</li><li style="width: 200px;float: left;list-style: none">',
    );
    echo $this->Form->radio('xyz_name',$myOptions,$attributes);
    ?>
     </li>
</ul>
+1
source

Source: https://habr.com/ru/post/1729611/


All Articles