Skip to content

Commit

Permalink
Merge pull request #32 from phillprice/feature/bootstrap-forms-blocker
Browse files Browse the repository at this point in the history
Allow blocking bootstrap_forms from the _config
  • Loading branch information
unclecheese committed Nov 21, 2014
2 parents 8ea7319 + c0f68bc commit 394c64e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: BootstrapForm
BootstrapForm:
bootstrap_included: false
jquery_included: false
bootstrap_form_included: false
inline_fields:
- CheckboxField
- FormAction
Expand Down
17 changes: 15 additions & 2 deletions code/BootstrapForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @package boostrap_forms
*/
class BootstrapForm extends Form {




Expand Down Expand Up @@ -55,6 +55,17 @@ public static function set_jquery_included($bool = true) {
}


/**
* Sets form to disable/enable inclusion of bootstrap forms js
*
* @deprecated In 3.1
* @param bool $bool
*/
public static function set_bootstrap_form_included($bool = true) {
Config::inst()->update("BootstrapForm", "bootstrap_form_included", $bool);
}


/**
* Changes the templates of all the {@link FormField}
* objects in a given {@link FieldList} object to those
Expand Down Expand Up @@ -140,7 +151,9 @@ public function forTemplate() {
if(!$this->stat('jquery_included')) {
Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js");
}
Requirements::javascript(BOOTSTRAP_FORMS_DIR."/javascript/bootstrap_forms.js");
if(!$this->stat('bootstrap_form_included')) {
Requirements::javascript(BOOTSTRAP_FORMS_DIR."/javascript/bootstrap_forms.js");
}
$this->addExtraClass("form-{$this->formLayout}");
$this->applyBootstrap();
return parent::forTemplate();
Expand Down

0 comments on commit 394c64e

Please sign in to comment.