Tuesday, March 20, 2012

Doctrine Not Save Boolean Value to Database in Symfony

If you create a boolean field in the database and symfony renders it as a checkbox ( sfWidgetFormInputCheckbox ) in the form... AND DOCTRINE DOES NOT SAVE THE VALUE TO THE DATABASE, you have to a put the boolean validator on it and doctrine will save the value. That's the magic.
    $this->setValidators(array(
        ...,
        'enabled' => new sfValidatorBoolean(),
        ...,
    ));

No comments:

Post a Comment