Development

#7880 (AC2009: Day 9: Mistakes. Part 1.)

You must first sign up to be able to contribute.

Ticket #7880 (new documentation)

Opened 3 years ago

Last modified 3 years ago

AC2009: Day 9: Mistakes. Part 1.

Reported by: vassa Assigned to: fabien
Priority: minor Milestone:
Component: website Version: 1.4.1
Keywords: Cc: hal
Qualification: Unreviewed

Description

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.

Change History

12/14/09 21:40:49 changed by alecs

related: #7911

02/05/10 12:09:16 changed by hal

(In [27587]) [doc][1.4] Refs #7880. Corrected typo in sentence "*Form* more information"

02/05/10 12:11:36 changed by hal

vassa, would you let me know whether this issue still exists, please? The link is broken; would you mind posting the new URL? Thanks!

02/05/10 12:12:00 changed by hal

  • cc set to hal.