Last active
July 3, 2018 00:12
-
-
Save Suven/6325905 to your computer and use it in GitHub Desktop.
Revisions
-
Suven revised this gist
Aug 24, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ * ) * ); * * @link https://gist.github.com/Suven/6325905 */ class BootstrapFormHelper extends FormHelper { -
Suven created this gist
Aug 24, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ <?php App::uses('FormHelper', 'View/Helper'); /** * BootstrapFormHelper. * * Applies styling-rules for Bootstrap 3 * * To use it, just save this file in /app/View/Helper/BootstrapFormHelper.php * and add the following code to your AppController: * public $helpers = array( * 'Form' => array( * 'className' => 'BootstrapForm' * ) * ); * * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html */ class BootstrapFormHelper extends FormHelper { public function create($model = null, $options = array()) { $defaultOptions = array( 'inputDefaults' => array( 'div' => array( 'class' => 'form-group' ), 'label' => array( 'class' => 'col-lg-2 control-label' ), 'between' => '<div class="col-lg-10">', 'seperator' => '</div>', 'after' => '</div>', 'class' => 'form-control', ), 'class' => 'form-horizontal', 'role' => 'form', ); if(!empty($options['inputDefaults'])) { $options = array_merge($defaultOptions['inputDefaults'], $options['inputDefaults']); } else { $options = array_merge($defaultOptions, $options); } return parent::create($model, $options); } // Remove this function to show the fieldset & language again public function inputs($fields = null, $blacklist = null, $options = array()) { $options = array_merge(array('fieldset' => false), $options); return parent::inputs($fields, $blacklist, $options); } public function submit($caption = null, $options = array()) { $defaultOptions = array( 'class' => 'btn btn-primary', 'div' => 'form-group', 'before' => '<div class="col-lg-offset-2 col-lg-10">', 'after' => '</div>', ); $options = array_merge($defaultOptions, $options); return parent::submit($caption, $options); } }