Skip to content

Instantly share code, notes, and snippets.

@csrui
Created January 8, 2014 11:20
Show Gist options
  • Save csrui/8315389 to your computer and use it in GitHub Desktop.
Save csrui/8315389 to your computer and use it in GitHub Desktop.
Formats CakePHP form elements with Bootstrap classes
<?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