Forked from henrikbjorn/sfWidgetFormSchemaFormatterDef.class.php
Created
February 11, 2010 12:04
-
-
Save gestadieu/301458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class sfWidgetFormSchemaFormatterDef extends sfWidgetFormSchemaFormatter | |
{ | |
protected | |
$rowFormat = '<div class="row %row_class%">%label%%field%%help%%hidden_fields%</div>', | |
$helpFormat = '<span>%help%</span>', | |
$errorRowFormat = '%errors%', | |
$errorListFormatInARow = '<ul>%errors%</ul>', | |
$errorRowFormatInARow = '<li>%error%</li>', | |
$namedErrorRowFormatInARow = '<li>%name%: %error%</li>', | |
$decoratorFormat = ''; | |
/** | |
* Takes the default rendered row and adds error class if it contains errors. Also it adds the type | |
* of the input as class like radio checkbox text password or textarea if it is a textarea. | |
* | |
* @see sfWidgetFormSchemaFormatter::formatRow([....]) | |
*/ | |
public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) | |
{ | |
$row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); | |
if (!preg_match('/type="([a-z]+)"/', $row, $matches)) { | |
$matches[1] = 'textarea'; | |
} | |
return strtr($row, array( | |
'%row_class%' => count($errors) ? 'error ' . $matches[1] : $matches[1], | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment