Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question