The Comedy of Errors

You are viewing revision #5 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version or see the changes made in this revision.

« previous (#4)next (#6) »

  1. The missing echo
  2. The echo too much
  3. Rules for numbers
  4. Rules for enums

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:

<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:

<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:

array('count', 'number', 'integerOnly'=>true),

then try

array('count', 'numeric', 'integerOnly'=>true),

and only then look it up: 'numerical'.

Rules for enums ¶

In the model rules() method put:

array('format', 'range', 'in' => array('html', 'rss2', 'atom', 'json', 'xml')),

then later remind yourself that Yii is not SQL.

19 0
15 followers
Viewed: 22 395 times
Version: Unknown (update)
Category: Others
Written by: fsb fsb
Last updated by: Mike Mike
Created on: Dec 7, 2011
Last updated: 12 years ago
Update Article

Revisions

View all history

Related Articles