Yii Framework Forum: activeDropDownList with the options selected correctly when posted - Yii Framework Forum

Jump to content

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

activeDropDownList with the options selected correctly when posted Rate Topic: -----

#1 User is offline   Athos 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 07-January 11

Posted 28 February 2011 - 01:52 PM

Hi!

If I have a many to many relationship and use the following form field:
<?php echo CHtml::activeDropDownList($postModel, 'tags', Tag::model()->findAll(), array('multiple'=>true)); ?>


The options are selected correctly when I load the form for editing.
But if I change the selection and post the form with an error, the field is loaded again with the data already recorded, instead of the new selection.
If the post is to create and return with an error, the dropdown always back empty.

The framework does not automatically deal with this issue. What is the correct way to fix this?
Thanks Google Translator to helping me write the posts :)
0

#2 User is offline   creocoder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 198
  • Joined: 09-March 09
  • Location:*.php

Posted 01 March 2011 - 01:05 AM

Looks like 'tags' attribute is not safe in rules(). Check you have a rule for this attribute.
No good, no bad, only consequence.
1

#3 User is offline   Athos 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 07-January 11

Posted 01 March 2011 - 08:51 AM

Great!

'tags' is a relation and only now i learned that the relation also can/should be cited in the rules.
Thank you!
Thanks Google Translator to helping me write the posts :)
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