Adding A Button To A List Of Radio Options

Hi everyone. I have the following design request from my boss: he would like to have a create form where a radio button list is displayed, where every radio option represent one of the possible values taken from another table. The problem is he needs every choice to have his own button which pops-up an image of the respective element.

So the simple radioButtonList ain’t enough for I won’t be able to add buttons and modals to recall for each. First I tried creating a widget, but I couldn’t refer to the form when it came to invoke the “radioButton” method of CActiveForm.

My last try was to move the widget view code inside my “_form.php”. Things seem to work, however the value selected with radios won’t be submitted. This is my “_form.php” as of now.


<div class="form">

    <?php

    /** @var LesioneController $this */

    /** @var Lesione $model */

    /** @var AweActiveForm $form */

    $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(

    'id' => 'lesione-form',

    'enableAjaxValidation' => true,

    'enableClientValidation'=> false,

    )); 


    $sedi = SedeLesione::model()->findAll(array('order'=>'descrizione'));




    ?>





    <p class="note">

        <?php echo Yii::t('AweCrud.app', 'Fields with') ?> <span class="required">*</span>

        <?php echo Yii::t('AweCrud.app', 'are required') ?>.    </p>


    <?php echo $form->errorSummary($model) ?>

                                      

    <?php if($sedi != null): ?>

    <?php foreach($sedi as $idNumber=>$sede){

                 echo '<div id="radioPreview' . $idNumber . '"' . ' class="radioPreview">';

                 echo $form->radioButton($model, 'sede_lesione_id');

                 echo $sede->descrizione; 

            $this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'preview' . $sede->id)); ?>

     

            <div class="modal-header">

            <a class="close" data-dismiss="modal">&times;</a>

            <h4><?php echo $sede->descrizione?></h4>

            </div>

             

            <div class="modal-body">

            <p>placeholder n. <?php echo $sede->id ?></p>

            </div>

             

            <div class="modal-footer">

            <?php $this->widget('bootstrap.widgets.TbButton', array(

            'label' => 'Chiudi',

            'url' => '#',

            'htmlOptions' => array('data-dismiss' => 'modal'),

            )); ?>

            </div>

             

            <?php $this->endWidget(); ?>

            <?php $this->widget('bootstrap.widgets.TbButton', array(

            'label' => 'Visualizza',

            'type' => 'info',

            'size' => 'small',

            'htmlOptions' => array(

            'class'=>'pull-right',

            'data-toggle' => 'modal',

            'data-target' => '#' .'preview' . $sede->id,

            ),

            ));

            echo '</div>';

            echo '</br>';

                    

    }

?>


<?php endif; ?>

<?php echo $form->textFieldRow($model, 'descrizione', array('class' => 'span5')) ?>

			        			        			

    <div class="form-actions">

                <?php $this->widget('bootstrap.widgets.TbButton', array(

			'buttonType'=>'submit',

			'type'=>'primary',

			'label'=>$model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),

		)); ?>

        <?php $this->widget('bootstrap.widgets.TbButton', array(

			//'buttonType'=>'submit',

			'label'=> Yii::t('AweCrud.app', 'Cancel'),

			'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')

		)); ?>

    </div>


    <?php $this->endWidget(); ?>

</div>

Can anybody enlighten me? I feel like I’m close to the solution but I can’t just grasp it… :(