Difference between #3 and #4 of The Comedy of Errors

unchanged
Title
The Comedy of Errors
unchanged
Category
Others
unchanged
Tags
errors
changed
Content
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'.
Write new article
  • Written by: fsb
  • Updated by: Mike
  • Category: Others
  • Yii Version: 1.1
  • Votes: +20
  • Viewed: 6,748 times
  • Created on: Dec 7, 2011
  • Last updated: May 3, 2013
  • Tags: errors comedy