unchanged
Title
The Comedy of Errors
Please join the party by adding your own favorite Yii programming errors. Be
sure to leave at least a hint at the correction.
The missing echo
----------------
In the view put:
~~~
[php]
<h1>Edit item: <?php $model->label; ?></h1>
~~~
Now spend your time debugging why $model->label has no value set.
The echo too much
-----------------
In the view put:
~~~
[php]
<h1>Edit item: <?php echo $this->widget('CWidget'); ?></h1>
~~~
"Object of class CWidget could not be converted to string." A widget
may not have an echo.
Rules for numbers
-----------------
In the model rules() method put:
~~~
[php]
array('count', 'number', 'integerOnly'=>true),
~~~
then try
~~~
[php]
array('count', 'numeric', 'integerOnly'=>true),
~~~
and only then look it up: 'numerical'.
Rules for enums
---------------
In the model rules() method put:
~~~
[php]
array('format', 'range', 'in' => array('html', 'rss2', 'atom', 'json',
'xml')),
~~~
then later remind yourself that Yii is not SQL.