Tuesday 26 April 2011

How to put error message below the field in symfony form?

Hey,

Got to /lib/form/doctrine/BaseFormDoctrine.class.php
adn put following line in public function setup().
$row_format   = "<tr>\n<th>%label%</th>\n<td>%help%%field%%error%%hidden_fields%</td>\n</tr>\n";
$this->getWidgetSchema()->getFormFormatter()->setRowFormat($row_format);

see example below:


## /lib/form/doctrine/BaseFormDoctrine.class.php
<?php

/**
 * Project form base class.
 *
 * @package    passportServices
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormBaseTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
abstract class BaseFormDoctrine extends sfFormDoctrine
{
  public function setup()
  {     
    $row_format   = "<tr>\n<th>%label%</th>\n<td>%help%%field%%error%%hidden_fields%</td>\n</tr>\n";
    $this->getWidgetSchema()->getFormFormatter()->setRowFormat($row_format);     
  }
}

Cheers!

No comments:

Post a Comment