getFormFieldSchema() as $fieldname => $field) { $widgetSchema = $form->getWidgetSchema(); if((($widgetSchema[$fieldname] instanceof sfWidgetFormInput) || ($widgetSchema[$fieldname] instanceof sfWidgetFormInputPassword)) && !($widgetSchema[$fieldname] instanceof sfWidgetFormInputHidden) && !($widgetSchema[$fieldname] instanceof sfWidgetFormInputFile) && !($widgetSchema[$fieldname] instanceof sfWidgetFormInputCheckbox) ) { $widgetSchema[$fieldname]->setAttribute('class', $widgetSchema[$fieldname]->getAttribute('class').' textInput'); } $validatorSchema = $form->getValidatorSchema(); if(isset($validatorSchema[$fieldname]) && $validatorSchema[$fieldname]->getOption('required')) { $widgetSchema[$fieldname]->setAttribute('class', $widgetSchema[$fieldname]->getAttribute('class').' required'); $widgetSchema[$fieldname]->setLabel($widgetSchema[$fieldname]->getLabel().' *'); } } } public static function setJqUiFormater(sfForm $form) { $widgetSchema = $form->getWidgetSchema(); $widgetSchema->addFormFormatter('jqUi', new jqUiFormSchemaFormaterTable($widgetSchema)); $widgetSchema->setFormFormatterName('jqUi'); } public static function setJqUiAdvanceFormater(sfForm $form) { $widgetSchema = $form->getWidgetSchema(); $widgetSchema->addFormFormatter('jqUiAdvance', new jqUiAdvanceFormSchemaFormaterTable($widgetSchema)); $widgetSchema->setFormFormatterName('jqUiAdvance'); } } class jqUiFormSchemaFormaterTable extends sfWidgetFormSchemaFormatterTable { protected $errorListFormatInARow = "
\n%errors%
\n"; protected $errorRowFormatInARow = '

%error%

'; protected $namedErrorRowFormatInARow = '

%error%

'; protected $rowFormat = "\n %label%\n %error%%field%%help%%hidden_fields%\n\n"; public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { preg_match("(for=\"(.*?)\")", $label, $out); $row_class = strlen($out[1]) > 0 ? $out[1].'_row' : ''; return strtr($this->getRowFormat(), array( '%label%' => $label, '%field%' => $field, '%error%' => $this->formatErrorsForRow($errors), '%help%' => $this->formatHelp($help), '%hidden_fields%' => null === $hiddenFields ? '%hidden_fields%' : $hiddenFields, '%row_class%' => $row_class, )); } } class jqUiAdvanceFormSchemaFormaterTable extends jqUiFormSchemaFormaterTable { protected $rowFormat = "\n %label%\n\n\n %error%%field%%help%%hidden_fields%\n\n"; protected $errorRowFormat = "\n%errors%\n"; }