Yii Framework Forum: Getting value from dropDownList - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Getting value from dropDownList Rate Topic: -----

#1 User is offline   jeraldtc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 06-December 15

Posted 11 December 2015 - 02:17 AM

I have this code in my view that search for the work position listed in the database (work_tbl). My question is how can I get what the user has selected in the dropDownList and save it to another table named users_tbl..? I only want to get the work_id from the dropDownList.

I also have 2 model: UserModel and WorkModel

<div class="row">
<?php echo $form->dropDownList($modelwork,'work_id', CHtml::listData(Work::model()->findAll(), 'work_id', 'work'),

	array(
		'empty' => 'Select Work',
		)
); ?> 
</div>


Thanks! :)


Just like in native php, I want to get the name (example below: work_dropdown) of the dropdownlist :) How can I do that in Yii?

<select name="work_dropdown">
   <option value="php">Native Php Developer</option>
   <option value="yii">Yii Developer</option>
   <option value="qa">Quality Assurance</option>
</select>

0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,062
  • Joined: 16-February 11
  • Location:Japan

Posted 11 December 2015 - 09:30 PM

You can just get the values of ModelWork in your controller. It should be populated with the "work_id" that the user has selected.

Please take a look at the "Working with Forms" sections of the guide.
http://www.yiiframew...n/form.overview
1

#3 User is offline   jeraldtc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 06-December 15

Posted 14 December 2015 - 01:37 AM

View Postsoftark, on 11 December 2015 - 09:30 PM, said:

You can just get the values of ModelWork in your controller. It should be populated with the "work_id" that the user has selected.

Please take a look at the "Working with Forms" sections of the guide.
http://www.yiiframew...n/form.overview


Thank you!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users