Improved Plugin for Model Validation: sfPropelValidatePlugin

I have updated my plugin for doing model-based validation in symfony. The new plugin uses the Propel builders instead of behaviors, so it is now called sfPropelValidatePlugin instead of the former (unwieldy) name sfPropelValidateBehaviorPlugin. If you have not investigated the Propel builder classes, I suggest you give them a look. By overriding the default classes used to build your Propel object and peer classes, you can write your modifications directly into your model’s base classes. This is a much cleaner and more readable solution than using Propel behaviors, and you avoid the performance hit that behaviors incur.

The default Propel builders can be found in the symfony source in these places:


The classes these inherit from are buried. They can be found here:

  1. Thierry Schellenbach’s avatar

    In fact I didn’t look at builders yet. Could you post a tutorial?

  2. Lucas’s avatar

    Hi Nice plugin, i just made some modifications.
    if (!$article->save()) {
    $this->forward(‘patient’, ‘edit’);
    sometimes does not returns true even if the validations succed, if you model has not been modified for ex, your post will always been forwarded.

    The solution i found was adding the following to sfValidateObjBuilder.php:

    $updated = ‘
    if(!$this->isModified()) return true;
    $tmp = preg_replace(‘/(:save:pre.*?}.*?})/s’, ‘\1′.$updated, $tmp, 1);

    Cheers L