Page: http://www.symfony-project.org/advent_calendar/9/en
Suppose your designer has already implemented the stylesheet that will apply the error styling to any input field inside a div with the class form_error_row. How can we easily add the form_row_error class to the fields with errors?
Please change "form_error_row" to "form_row_error".
Though the format of this class is strange, the general idea is that the renderRow() method will use the $rowFormat markup to organize its output. A form schema formatter class offers many other formatting options which I won't cover here in detail. Form more information, consult the symfony 1.3 API.
Please change "Form" to "For".
Code block:
class sfWidgetFormSchemaFormatterAc2009 extends sfWidgetFormSchemaFormatter
{
protected
$rowFormat = "<div class="form_row">
%label% \n %error% <br/> %field%
%help% %hidden_fields%\n</div>\n",
$errorRowFormat = "<div>%errors%</div>",
$helpFormat = '<div class="form_help">%help%</div>',
$decoratorFormat = "<div>\n %content%</div>";
}
These quotes must be escaped by slash.
Code block:
class sfWidgetFormSchemaFormatterAc2009 extends sfWidgetFormSchemaFormatter
{
protected
$rowFormat = "<div class="form_row%row_class%">
%label% \n %error% <br/> %field%
%help% %hidden_fields%\n</div>\n",
// ...
public function formatRow($label, $field, $errors = array(), $help = , $hiddenFields = null)
{
$row = parent::formatRow(
$label,
$field,
$errors,
$help,
$hiddenFields
);
return strtr($row, array(
'%row_class%' => (count($errors) > 0) ? ' form_row_error' : ,
));
}
}
These quotes must be escaped by slash. IMHO "form_row%row_class%" should be changed by the "%row_class%".
Code block:
// lib/validator/ProductPhotoValidatorSchema.class.php
class ProductPhotoValidatorSchema? extends sfValidatorSchema
{
...
// filename is filled but no caption
if ($valuefilename? && !$valuecaption?)
{
$errorSchemaLocal->addError(new sfValidatorError($this, 'required'), 'caption');
}
// caption is filled but no filename
if ($valuecaption? && !$valuefilename?)
{
$errorSchemaLocal->addError(new sfValidatorError($this, 'required'), 'filename');
}
...
}
There are 'caption' and 'filename' at these places, aren't it?
Sorry for my bad English.