Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow blocking bootstrap_forms from the _config #32

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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