D
D
des1roer2015-05-12 10:34:40
Yii
des1roer, 2015-05-12 10:34:40

Yii find out id textfield?

I create fields like this

for($i = 0; $i < count($rows); $i++)
                {
                    echo CHtml::label($rows[$i]['name'], $rows[$i]['name']);
                    echo CHtml::textField('elem[]','',array('id'=>$rows[$i]['name']));                  
                }

and in the controller
foreach($_POST['elem'] as $check)
                                    {
                                         $Ids = $_POST['elem'];
                                    };

so here i get
array(2) {
  [0]=>
  string(3) "231"
  [1]=>
  string(1) "4"
}

how to get field id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-05-12
@des1roer

You can find out on the frontend in your case with the help of some jquery.
No way on the backend, because you didn't pass the information by id in the form.
Names should be set like this:

$id = rows[$i]['name'];
echo CHtml::textField('elem[$id][]','',array('id'=>$id));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question