Forked from malteo/sfWidgetFormSchemaFormatterBootstrap.class.php
Created
October 20, 2012 05:20
-
-
Save calvin/3922130 to your computer and use it in GitHub Desktop.
Symfony form formatter to use with Twitter Bootstrap CSS
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 | |
/** | |
* A FormSchemaFormatter to use with Twitter Bootstrap CSS. | |
* | |
* @author malteo | |
*/ | |
class sfWidgetFormSchemaFormatterBootstrap extends sfWidgetFormSchemaFormatter | |
{ | |
protected | |
$rowFormat = "<div class=\"clearfix%row_class%\">\n %label%\n <div class=\"input\">\n %field%\n %error%\n %help%\n %hidden_fields%\n </div>\n</div>\n", | |
$errorRowFormat = '%errors%', | |
$errorListFormatInARow = "<span class=\"help-inline\">%errors%</span>\n", | |
$errorRowFormatInARow = "%error% ", | |
$namedErrorRowFormatInARow = "%name%: %error% ", | |
$helpFormat = '<span class="help-block">%help%</span>', | |
$decoratorFormat = '%content%'; | |
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) ? ' error' : '', | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Show embedded forms.