views:

6

answers:

1

I have a field that is defined as follows:

class Subcategory extends BaseSubcategory {}

abstract class BaseSubcategory extends Doctrine_Record
{
    public function setTableDefinition()
    {
        // ...
        $this->hasColumn('meta_description', 'string', 255);
        // ...
    }

    // ...
}

Here's what the table looks like:

mysql> DESCRIBE subcategory;
+----------------------+------------------+------+-----+---------+----------------+
| Field                | Type             | Null | Key | Default | Extra          |
+----------------------+------------------+------+-----+---------+----------------+
| id                   | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
[...]
| meta_description     | varchar(255)     | YES  |     | NULL    |                |
[...]
+----------------------+------------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)

Here's my code to save a record

$m = new Subcategory;
// ...
$m->meta_description = null;
$m->save();

I'm getting the following validation error

* 1 validator failed on meta_description (length)

Why is this happening?

A: 

The code samples above do not tell the whole story. I was being misled by an earlier save, in which the meta_description field was being overloaded with over 255 characters. False alarm!

mattalexx