Saturday, September 11, 2010

custom form formatter/decorators

symfony 1.4 form

custom form formatter/decorators

class xxxForm extends BaseXxxForm
{
  public function configure()
  {
    $myDecorator = new myListFormDecorator($this->getWidgetSchema());
    $this->widgetSchema->addFormFormatter('custom', $myDecorator);
    $this->widgetSchema->setFormFormatterName('custom');
  }
}

class myListFormDecorator extends sfWidgetFormSchemaFormatter {
  protected
    $rowFormat = "
      %hidden_fields% %field% %help%
    ",
    $helpFormat = '<div class="help">%help%</div>',
    $errorRowFormat = "%error%",
    $errorListFormatInARow = " ",
    $errorRowFormatInARow = " ",
    $namedErrorRowFormatInARow = " ",
    $decoratorFormat = "%content%";
}// decorator class

No comments: