Rational Yii Shoe

Can anyone talk about how to determine which radio button was selected when submitting the form?

I use CActiveForm::radioButtonList?

+3
source share
2 answers

You do not need to define it. The client will transmit its value in the POSTdata.

For example, such a code

<?=$form->radioButtonList($person,'gender_code',array('m'=>'Male','f'=>'Female')); ?>

forms POST[gender_code]=morPOST[gender_code]=f

+4
source

Radio List Reflects a simple form by submitting a process. If you have the following list implementation e.g.

 <div class="form">
<?php echo CHtml::beginForm(); ?>     
    <div class="row">
        <?php
            echo CHtml::radioButtonList(
                    'registerMode',
                    'consumer',
                    array(
                        'consumer'=>'I am a FOODIE ',
                        'staff'=>'I want to give Services ',
                    ),
                    array('template'=>'<div class="rb">{input}</div><div class="rb">{label}</div><div class="clear">&nbsp;</div>')
                );
        ?>
    </div>     
    <div class="row">
        <?php echo CHtml::submitButton('Register',array('class'=>'submit')); ?>
    </div>

<?php echo CHtml::endForm(); ?>
</div><!-- form -->

when the next input is sent

array
(
    'registerMode' => 'consumer'
    'yt0' => 'Register'
)

it represents the name or index of the selected option

the following code can get the values

  if(isset($_POST['registerMode']))
         CVarDumper::Dump($_POST['registerMode'],100,true);

Luck

+4
source

All Articles