List Of Radio Button To Enable One Model Over Multiple

Hello :)

I created a wizard for one of my form allowing to set multiple models information in defferent step. However among these models, only one has to have a certain option checked. So in the last step I would like to ask which model will have "this option" enabled. I firstly think to use radio button.

My first idea was to create a unique radio button for each model, using javascript you can then forbid to check more than one radio button in same time… but it’s a bit dodgy :




  <div class="step" id="6">

    <div class="row">

      <b><?php echo "Enable :"; ?></b>

      </br>

      <?php echo "model 0   "; ?>

      <?php echo $form->radioButton($model[0],'[0]enabled',false); ?>

      </br></br>

      <?php echo "model 1   "; ?>

      <?php echo $form->radioButton($model[1],'[1]enabled',false); ?>

      </br></br>

      <?php echo "model 2   "; ?>

      <?php echo $form->radioButton($model[2],'[2]enabled',false); ?>

      </br></br>

      <?php echo "model 3   "; ?>

      <?php echo $form->radioButton($model[3],'[3]enabled',false); ?>

    </div>



The other idea was to create a radio button list, however it uses only one model ?? I think.

My question was more can you use radio button list with multiple model or should I use my first idea ?

thanks.

Nobody can help me ?

Hi

Have you tried using CFormModel? I found it to be quite flexible for what you are trying to do. It will allow you to create a custom validation rule for the radio buttons and once it is validated, you can then save the data in your different models.

The point is that I don’t really want to try to get around the problem… I could of course use one of my model, create a new attribute and read the value of this attribute in order to know which model I’m gonna enabled… but it looks very ugly. That’s the point of my topic, is there a way to get a list of radio button concerning the same attributes but of different model ?

Hi Zugluk

Based on your requirements and restrictions, the answer to your topic is No. IMHO, Javascript is the solution.

Javascript is not the solution to manage what I want