D
D
des1roer2015-05-08 10:33:43
Yii
des1roer, 2015-05-08 10:33:43

Yii checkboxlist + textfield?

I form a checkboxlist to save the many-to-many relationship. but in the same table I want to prescribe one more field.
I have this for
HuiTaox.png
now, but here's how to pass the id of the current checkbox to the textField id?

<?php
            //данные для элементов    
            $type_list = CHtml::listData(Element::model()->findAll(), 'id', 'name');

            if (isset($model->id))
            {
                $arr = HasElem::model()->findAll("template_id=:id", array(':id' => $model->id));
            }

            if (isset($arr))
            {
                for($i = 0; $i < count($arr); $i++)
                {                    
                    $arr_bit[] = $arr[$i]->elem_id;
                }
            }
            else
                $arr_bit = array();

            $data = CHtml::textField('textField'); 
            echo CHtml::checkBoxList('im_id2', $arr_bit, $type_list, array(
                'template' => "{input} {labelTitle} $data",
                'class' => 'chclass',
                'labelOptions'=>array('style'=>'display:inline'),
                    )
            );
            //просто рисуем чекбокслитс из базы
            //данные для элементов
            ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question