Yii Framework Forum: changeing the value write to mysql table from GUI will pull downs. - Yii Framework Forum

Jump to content

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

changeing the value write to mysql table from GUI will pull downs. Rate Topic: -----

#1 User is offline   GabeD 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 16-October 09

Posted 16 October 2009 - 09:47 AM

I have an application that pulls data from tables to populate pull down fields. When the application writes the data to the primary table it uses the index to the pull down value and not the actually value. I want the application to write the value from the pull down window and not the index value to the field.

Can someone point me to where yii writes out the values that I can modify?
0

#2 User is offline   Backslider 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 292
  • Joined: 23-July 09

Posted 16 October 2009 - 10:18 PM

Not sure how you are building your drop down, it should be something like this:

<?php echo CHtml::activeDropDownList($model, 'my_select_var', CHtml::listData(Myclass::model()->findAll(),'my_value','my_value'), array('prompt'=>'Please Select')); ?>


So really, there is no need to change anything if you populate the pull down how you want.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#3 User is offline   GabeD 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 16-October 09

Posted 19 October 2009 - 10:30 AM

Thanks for the reply. I will try and incorporate this approch.

What I current have is
<?php echo CHtml::activeLabelEx($model,'cpeType_id'); ?>
<?php echo CHtml::activeDropDownList($model,'cpeType_id',CHtml::listData(CActiveRecord::model('CpeType')->findAll(),'id','model')); ?>
</div>
this is pulling 2 values('id','model') from an sql table "CpeType" and populating the pulldown with the values for 'model'

when I do a submit from the from, the form inserts the value for 'id' in the database record and not the value of model. I would prefer that the submit uses the value form the pulldown for the model and not the 'id' value.
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