diff --git a/_config/config.yml b/_config/config.yml index 49ddec8..1689705 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -25,6 +25,9 @@ TextareaField: FieldList: extensions: - BootstrapFieldList +Injector: + MemberLoginForm: + class: BootstrapMemberLoginForm --- only: moduleexists: userforms diff --git a/code/BootstrapFieldList.php b/code/BootstrapFieldList.php index 12e6848..0ab03e5 100644 --- a/code/BootstrapFieldList.php +++ b/code/BootstrapFieldList.php @@ -8,6 +8,8 @@ class BootstrapFieldList extends Extension { public function bootstrapify() { + $inline_fields = Config::inst()->get('BootstrapForm','inline_fields'); + foreach($this->owner as $f) { @@ -23,6 +25,10 @@ public function bootstrapify() { $f->Fields()->bootstrapify(); } + if(!in_array($f->class, $inline_fields )) { + $f->addExtraClass('form-control'); + } + $template = "Bootstrap{$f->class}_holder"; if(SSViewer::hasTemplate($template)) { $f->setFieldHolderTemplate($template); diff --git a/code/BootstrapForm.php b/code/BootstrapForm.php index 17a12ae..6ff330c 100755 --- a/code/BootstrapForm.php +++ b/code/BootstrapForm.php @@ -66,20 +66,6 @@ public static function set_bootstrap_form_included($bool = true) { } - /** - * Changes the templates of all the {@link FormField} - * objects in a given {@link FieldList} object to those - * that work the Bootstrap framework - * - * @param FieldList $fields - */ - public static function apply_bootstrap_to_fieldlist($fields) { - $fields->bootstrapify(); - } - - - - /** * Applies the Bootstrap transformation to the fields and actiosn * of the form @@ -87,28 +73,13 @@ public static function apply_bootstrap_to_fieldlist($fields) { * @return BootstrapForm */ public function applyBootstrap() { - $this->applyBootstrapToFieldList($this->Fields()); - $this->applyBootstrapToFieldList($this->Actions()); - return $this; - } - + $this->Fields()->bootstrapify(); + $this->Actions()->bootstrapify(); - - /** - * Changes the templates of all the {@link FormField} - * objects in a given {@link FieldList} object to those - * that work the Bootstrap framework - * - * @param FieldList $fields - * @return BootstrapForm - */ - protected function applyBootstrapToFieldList($fields) { - self::apply_bootstrap_to_fieldlist($fields); return $this; } - /** * Sets the desired layout of the form. Options include: * - "vertical" (default) diff --git a/code/BootstrapFormField.php b/code/BootstrapFormField.php index f0c4ead..502ed69 100755 --- a/code/BootstrapFormField.php +++ b/code/BootstrapFormField.php @@ -166,21 +166,6 @@ public function HolderClasses() { return implode(" ",$this->holderClasses); } - /** - * Adds requisite classes to the form field - * - * @return BootstrapFormField - */ - public function onBeforeRender() { - if( - !in_array($this->owner->class, Config::inst()->get('BootstrapForm','inline_fields')) && - ($this->owner->getForm() && $this->owner->getForm() instanceof BootstrapForm) - ) { - $this->owner->addExtraClass('form-control'); - } - return $this->owner; - } - /** * checks for error messages in owner form field * adds error class to holder and loads error message as helptext diff --git a/code/BootstrapMemberLoginForm.php b/code/BootstrapMemberLoginForm.php index e667b14..44a372e 100644 --- a/code/BootstrapMemberLoginForm.php +++ b/code/BootstrapMemberLoginForm.php @@ -10,6 +10,8 @@ public function __construct($controller = null, $name = null, $fields = null, $a $this->Fields()->bootstrapify(); $this->Actions()->bootstrapify(); $this->setTemplate("BootstrapForm"); + + $this->invokeWithExtensions('updateBoostrapMemberLoginForm', $this); } } \ No newline at end of file