diff --git a/.upgrade.yml b/.upgrade.yml new file mode 100644 index 0000000..06ad44d --- /dev/null +++ b/.upgrade.yml @@ -0,0 +1,14 @@ +mappings: + ChosenDropdownField: UncleCheese\BootstrapForms\ChosenDropdownField + BootstrapUserForm: UncleCheese\BootstrapForms\BootstrapUserForm + BootstrapFormAction: UncleCheese\BootstrapForms\BootstrapFormAction + BootstrapTextField: UncleCheese\BootstrapForms\BootstrapTextField + BootstrapFormField: UncleCheese\BootstrapForms\BootstrapFormField + ChosenListboxField: UncleCheese\BootstrapForms\ChosenListboxField + SimpleHtmlEditorField: UncleCheese\BootstrapForms\SimpleHtmlEditorField + BootstrapButtonGroupField: UncleCheese\BootstrapForms\BootstrapButtonGroupField + BootstrapDropdownField: UncleCheese\BootstrapForms\BootstrapDropdownField + BootstrapForm: UncleCheese\BootstrapForms\BootstrapForm + BootstrapFieldList: UncleCheese\BootstrapForms\BootstrapFieldList + BootstrapOptionsetField: UncleCheese\BootstrapForms\BootstrapOptionsetField + BootstrapMemberLoginForm: UncleCheese\BootstrapForms\BootstrapMemberLoginForm diff --git a/_config/config.yml b/_config/config.yml index 853ed32..9c11a1d 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -1,38 +1,39 @@ +--- name: BootstrapForm --- -BootstrapForm: +UncleCheese\BootstrapForms\BootstrapForm: bootstrap_included: false jquery_included: false bootstrap_form_included: false bootstrap_select_included: false inline_fields: - - CheckboxField - - FormAction -FormField: + - SilverStripe\Forms\CheckboxField + - SilverStripe\Forms\FormAction +SilverStripe\Forms\FormField: extensions: - - BootstrapFormField -TextField: + - UncleCheese\BootstrapForms\BootstrapFormField +SilverStripe\Forms\TextField: extensions: - - BootstrapTextField -OptionsetField: + - UncleCheese\BootstrapForms\BootstrapTextField +SilverStripe\Forms\OptionsetField: extensions: - - BootstrapOptionsetField -FormAction: + - UncleCheese\BootstrapForms\BootstrapOptionsetField +SilverStripe\Forms\FormAction: extensions: - - BootstrapFormAction -TextareaField: + - UncleCheese\BootstrapForms\BootstrapFormAction +SilverStripe\Forms\TextareaField: extensions: - - BootstrapTextField -FieldList: + - UncleCheese\BootstrapForms\BootstrapTextField +SilverStripe\Forms\FieldList: extensions: - - BootstrapFieldList -Injector: - MemberLoginForm: - class: BootstrapMemberLoginForm + - UncleCheese\BootstrapForms\BootstrapFieldList +SilverStripe\Core\Injector\Injector: + SilverStripe\Security\MemberAuthenticator\MemberLoginForm: + class: UncleCheese\BootstrapForms\BootstrapMemberLoginForm --- only: moduleexists: userforms --- -UserDefinedForm_Controller: +SilverStripe\UserForms\Control\UserDefinedFormController: extensions: - - BootstrapUserForm + - UncleCheese\BootstrapForms\BootstrapUserForm diff --git a/code/BootstrapButtonGroupField.php b/code/BootstrapButtonGroupField.php index 6244f53..1f9bfde 100644 --- a/code/BootstrapButtonGroupField.php +++ b/code/BootstrapButtonGroupField.php @@ -1,5 +1,12 @@ owner as $f) { - $sng = Injector::inst()->get($f->class, true, ['dummy', '']); + $sng = Injector::inst()->get(get_class($f), true, ['dummy', '']); if(isset($this->ignores[$f->getName()])) continue; @@ -39,19 +49,20 @@ public function bootstrapify() { // If the user has customised the holder template already, don't apply the default one. if($sng->getFieldHolderTemplate() == $f->getFieldHolderTemplate()) { - $template = "Bootstrap{$f->class}_holder"; - if(SSViewer::hasTemplate($template)) { - $f->setFieldHolderTemplate($template); + $className = substr(strrchr(get_class($f), "\\"), 1); + $template = "UncleCheese\\BootstrapForms\\Bootstrap{$className}_holder"; + if(SSViewer::hasTemplate($template)) { + $f->setFieldHolderTemplate($template); } - else { - $f->setFieldHolderTemplate("BootstrapFieldHolder"); + else { + $f->setFieldHolderTemplate("UncleCheese\\BootstrapForms\\BootstrapFieldHolder"); } } // If the user has customised the field template already, don't apply the default one. if($sng->getTemplate() == $f->getTemplate()) { - foreach(array_reverse(ClassInfo::ancestry($f)) as $className) { + foreach(array_reverse(ClassInfo::ancestry($f)) as $className) { $bootstrapCandidate = "Bootstrap{$className}"; $nativeCandidate = $className; if(SSViewer::hasTemplate($bootstrapCandidate)) { @@ -68,12 +79,12 @@ public function bootstrapify() { } } - return $this->owner; + return $this->owner; } /** * Adds this field as ignored. Should not take on boostrap transformation - * + * * @param string $field The name of the form field * @return FieldList */ diff --git a/code/BootstrapForm.php b/code/BootstrapForm.php index 24a9e1f..dca35af 100755 --- a/code/BootstrapForm.php +++ b/code/BootstrapForm.php @@ -1,5 +1,11 @@ stat('bootstrap_included')!=false) { - Requirements::css(BOOTSTRAP_FORMS_DIR.'/css/bootstrap.css'); + Requirements::css('unclecheese/bootstrap-forms: css/bootstrap.css'); } if($this->stat('jquery_included')!=false) { - Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js"); + Requirements::javascript('silverstripe/adimin: thirdparty/jquery/jquery.js'); } if(!$this->stat('bootstrap_form_included')!=false) { - Requirements::javascript(BOOTSTRAP_FORMS_DIR."/javascript/bootstrap_forms.js"); + Requirements::javascript('unclecheese/bootstrap-forms: javascript/bootstrap_forms.js'); } $this->addExtraClass("form-{$this->formLayout}"); diff --git a/code/BootstrapFormAction.php b/code/BootstrapFormAction.php index d59df3e..220ff02 100755 --- a/code/BootstrapFormAction.php +++ b/code/BootstrapFormAction.php @@ -1,5 +1,9 @@ get('BootstrapForm','inline_fields'); + $inline_fields = Config::inst()->get(BootstrapForm::class,'inline_fields'); - if(!in_array($field->class, $inline_fields )) { + if(!in_array(get_class($field), $inline_fields )) { $field->addExtraClass('form-control'); } } diff --git a/code/BootstrapMemberLoginForm.php b/code/BootstrapMemberLoginForm.php index 44a372e..fdbd150 100644 --- a/code/BootstrapMemberLoginForm.php +++ b/code/BootstrapMemberLoginForm.php @@ -1,12 +1,21 @@ Fields()->bootstrapify(); $this->Actions()->bootstrapify(); $this->setTemplate("BootstrapForm"); @@ -14,4 +23,4 @@ public function __construct($controller = null, $name = null, $fields = null, $a $this->invokeWithExtensions('updateBoostrapMemberLoginForm', $this); } -} \ No newline at end of file +} diff --git a/code/BootstrapOptionsetField.php b/code/BootstrapOptionsetField.php index f16eac4..920cd8d 100755 --- a/code/BootstrapOptionsetField.php +++ b/code/BootstrapOptionsetField.php @@ -1,5 +1,8 @@ owner; } - - /** * Adds text immediately to the right, abut the form field * @@ -69,4 +69,4 @@ public function setSpan($span) { } -} \ No newline at end of file +} diff --git a/code/BootstrapUserForm.php b/code/BootstrapUserForm.php index 729b73e..eecc26c 100644 --- a/code/BootstrapUserForm.php +++ b/code/BootstrapUserForm.php @@ -1,5 +1,9 @@