Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aledujke/2023782 to your computer and use it in GitHub Desktop.
Save aledujke/2023782 to your computer and use it in GitHub Desktop.

Revisions

  1. aledujke revised this gist Apr 19, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sfWidgetFormSchemaFormatterBootstrap.class.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ class sfWidgetFormSchemaFormatterBootstrap extends sfWidgetFormSchemaFormatter
    $errorRowFormatInARow = "%error% ",
    $namedErrorRowFormatInARow = "%name%: %error% ",
    $helpFormat = '<p class="help-block">%help%</p>',
    $decoratorFormat = '';
    $decoratorFormat = '%content%';

    public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null)
    {
  2. aledujke revised this gist Mar 12, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sfWidgetFormSchemaFormatterBootstrap.class.php
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ public function formatRow($label, $field, $errors = array(), $help = '', $hidden
    );

    return strtr($row, array(
    '%row_class%' => (count($errors) > 0) ? ' error' : '',
    '%row_class%' => count($errors) ? ' error' : '',
    ));
    }

  3. aledujke revised this gist Mar 12, 2012. 1 changed file with 15 additions and 8 deletions.
    23 changes: 15 additions & 8 deletions sfWidgetFormSchemaFormatterBootstrap.class.php
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,13 @@
    <?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",
    $rowFormat = "<div class=\"control-group %row_class%\">\n %label%\n <div class=\"controls\">\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>',
    $helpFormat = '<p class="help-block">%help%</p>',
    $decoratorFormat = '';

    public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null)
    @@ -30,4 +24,17 @@ public function formatRow($label, $field, $errors = array(), $help = '', $hidden
    '%row_class%' => (count($errors) > 0) ? ' error' : '',
    ));
    }

    public function generateLabel($name, $attributes = array())
    {
    if(isset($attributes['class']))
    {
    $attributes['class'] .= ' control-label';
    }
    else
    {
    $attributes['class'] = 'control-label';
    }
    return parent::generateLabel($name, $attributes);
    }
    }
  4. @malteo malteo created this gist Nov 11, 2011.
    33 changes: 33 additions & 0 deletions sfWidgetFormSchemaFormatterBootstrap.class.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <?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 = '';

    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' : '',
    ));
    }
    }