tingobol / gii-template-collection

Automatically exported from code.google.com/p/gii-template-collection
0 stars 0 forks source link

Empty value in dropdown list should be really empty not zero #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create two related tables which foreign key is not required
2. Model and Crud them
3. Create a news child and try to update it

What is the expected output? What do you see instead?
Expected that the PK field accepts the "none" value, but due to the generated 
code in the Relation.php object, an exception is raised when you try to update 
a record which has a non-required foreign key

What version of the product are you using? On what operating system?
the latest provided in download section

Please provide any additional information below.
The problem can be solved easily by changing line 474 or Relation.php from:
[code]
array('0' => $this->allowEmpty),
[/code]

to
[code]
array('' => $this->allowEmpty),
[/code]

the "0" value in the dropdown is the problem because when you generate a 
dropdown manually like in 
$form->dropDownList($model, 'att', 
CHtml::listData(Related::model()->findAll(),'id','name'), 
array('empty'=>'None'))

everything works with the Yii resultant dropdown which does not include "0" in 
the empty value

thats say  0 <> empty so if you try to set "0", MySQL raises an error 

regards

Original issue reported on code.google.com by scoob.ju...@gmail.com on 26 Jul 2010 at 1:41

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r92.

Original comment by robregonm on 3 Sep 2010 at 10:55