Created
January 8, 2014 11:20
-
-
Save csrui/8315389 to your computer and use it in GitHub Desktop.
Formats CakePHP form elements with Bootstrap classes
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 characters
<?php | |
/** | |
* Formats form elements for Bootstrap v3 | |
* | |
* Add to AppController.php | |
* | |
* public $helpers = array( | |
* 'Form' => array('className' => 'BootstrapForm') | |
* ); | |
* | |
**/ | |
App::uses('FormHelper', 'View/Helper'); | |
class BootstrapFormHelper extends FormHelper { | |
public function create($model = null, $options = array()) { | |
$defaultOptions = array( | |
'inputDefaults' => array( | |
'div' => 'form-group', | |
'wrapInput' => false, | |
'class' => 'form-control' | |
) | |
); | |
$options = Hash::merge($defaultOptions, $options); | |
return parent::create($model, $options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment