php - Text field or dropdown list in yii


I have two tables:supa and acts. Supa table has ID as primary key and and Acts table has supa_ID as a foreign key that is connecting this tables. Now in table Supa I has field that is called "oznaka". I suppose to create text field where I will put "oznaka", but in background it is suppose to take ID of Supa table, connect with table Acts, find supa_ID and put him there. I have troubles with controller function - I suppose I use view - controller only. This doesn't suppose to be hard but I have really trouble :(




<?php echo $form->dropDownList($model,'item_type_id', CHtml::listData(ItemType::model()->findAll(), 'id', 'type'), array('empty'=>'select Type')); ?>

This is basic usage in Yii to create dropdown list, populated from database. If You want text box, You can make ajax call after some input is received to check whether in database is something that corresponds to this input. If there is, add new value to some hidden input field and get that data when form is sumbitted, in controller.

People are also looking for solutions to the problem: How to use php_codesniffer for upgrading and compatibility check (PHP 5.2 against PHP 5.4)


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.