diff --git a/code/model/formfields/EditableCheckbox.php b/code/model/editableformfields/EditableCheckbox.php similarity index 90% rename from code/model/formfields/EditableCheckbox.php rename to code/model/editableformfields/EditableCheckbox.php index e1e0bbc..31b504b 100755 --- a/code/model/formfields/EditableCheckbox.php +++ b/code/model/editableformfields/EditableCheckbox.php @@ -32,8 +32,12 @@ class EditableCheckbox extends EditableFormField { } public function getFormField() { - $field = CheckboxField::create($this->Name, $this->EscapedTitle, $this->CheckedDefault); + $field = CheckboxField::create($this->Name, $this->EscapedTitle, $this->CheckedDefault) + ->setFieldHolderTemplate('UserFormsCheckboxField_holder') + ->setTemplate('UserFormsCheckboxField'); + $this->doUpdateFormField($field); + return $field; } diff --git a/code/model/editableformfields/EditableCountryDropdownField.php b/code/model/editableformfields/EditableCountryDropdownField.php index 741f51b..e3c68f6 100644 --- a/code/model/editableformfields/EditableCountryDropdownField.php +++ b/code/model/editableformfields/EditableCountryDropdownField.php @@ -23,8 +23,12 @@ class EditableCountryDropdownField extends EditableFormField { } public function getFormField() { - $field = CountryDropdownField::create($this->Name, $this->EscapedTitle); + $field = CountryDropdownField::create($this->Name, $this->EscapedTitle) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsDropdownField'); + $this->doUpdateFormField($field); + return $field; } diff --git a/code/model/editableformfields/EditableDateField.php b/code/model/editableformfields/EditableDateField.php index c16ab87..e0a81e6 100755 --- a/code/model/editableformfields/EditableDateField.php +++ b/code/model/editableformfields/EditableDateField.php @@ -43,9 +43,14 @@ class EditableDateField extends EditableFormField { $defaultValue = $this->DefaultToToday ? SS_Datetime::now()->Format('Y-m-d') : $this->Default; - $field = EditableDateField_FormField::create( $this->Name, $this->EscapedTitle, $defaultValue); - $field->setConfig('showcalendar', true); + + $field = EditableDateField_FormField::create( $this->Name, $this->EscapedTitle, $defaultValue) + ->setConfig('showcalendar', true) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsField'); + $this->doUpdateFormField($field); + return $field; } } diff --git a/code/model/editableformfields/EditableDropdown.php b/code/model/editableformfields/EditableDropdown.php index a8d6ad4..8ebb72c 100755 --- a/code/model/editableformfields/EditableDropdown.php +++ b/code/model/editableformfields/EditableDropdown.php @@ -28,7 +28,9 @@ class EditableDropdown extends EditableMultipleOptionField { * @return DropdownField */ public function getFormField() { - $field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()); + $field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsDropdownField'); // Set default $defaultOption = $this->getDefaultOptions()->first(); diff --git a/code/model/editableformfields/EditableEmailField.php b/code/model/editableformfields/EditableEmailField.php index 8f9eb9c..ac2a2d6 100755 --- a/code/model/editableformfields/EditableEmailField.php +++ b/code/model/editableformfields/EditableEmailField.php @@ -18,8 +18,12 @@ class EditableEmailField extends EditableFormField { } public function getFormField() { - $field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default); + $field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsField'); + $this->doUpdateFormField($field); + return $field; } diff --git a/code/model/editableformfields/EditableFieldGroup.php b/code/model/editableformfields/EditableFieldGroup.php index 55d8d0c..6e2ca52 100644 --- a/code/model/editableformfields/EditableFieldGroup.php +++ b/code/model/editableformfields/EditableFieldGroup.php @@ -54,7 +54,8 @@ class EditableFieldGroup extends EditableFormField { public function getFormField() { $field = UserFormsGroupField::create() - ->setTitle($this->EscapedTitle ?: false); + ->setTitle($this->EscapedTitle ?: false) + ->setName($this->Name); $this->doUpdateFormField($field); return $field; } diff --git a/code/model/editableformfields/EditableFileField.php b/code/model/editableformfields/EditableFileField.php index 5cff5a2..6e66acc 100755 --- a/code/model/editableformfields/EditableFileField.php +++ b/code/model/editableformfields/EditableFileField.php @@ -35,7 +35,9 @@ class EditableFileField extends EditableFormField { } public function getFormField() { - $field = FileField::create($this->Name, $this->EscapedTitle); + $field = FileField::create($this->Name, $this->EscapedTitle) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsFileField'); // filter out '' since this would be a regex problem on JS end $field->getValidator()->setAllowedExtensions( diff --git a/code/model/editableformfields/EditableFormHeading.php b/code/model/editableformfields/EditableFormHeading.php index c3274e2..87bf6d7 100755 --- a/code/model/editableformfields/EditableFormHeading.php +++ b/code/model/editableformfields/EditableFormHeading.php @@ -29,8 +29,7 @@ class EditableFormHeading extends EditableFormField { public function getCMSFields() { $fields = parent::getCMSFields(); - $fields->removeByName('Default'); - $fields->removeByName('Validation'); + $fields->removeByName(array('Default', 'Validation', 'RightTitle')); $levels = array( '1' => '1', diff --git a/code/model/editableformfields/EditableFormStep.php b/code/model/editableformfields/EditableFormStep.php index 294f6b2..acc7bab 100644 --- a/code/model/editableformfields/EditableFormStep.php +++ b/code/model/editableformfields/EditableFormStep.php @@ -24,7 +24,7 @@ class EditableFormStep extends EditableFormField { public function getCMSFields() { $fields = parent::getCMSFields(); - $fields->removeByName(array('MergeField', 'Default', 'Validation')); + $fields->removeByName(array('MergeField', 'Default', 'Validation', 'RightTitle')); return $fields; } diff --git a/code/model/editableformfields/EditableLiteralField.php b/code/model/editableformfields/EditableLiteralField.php index 109d4a9..dcc82da 100644 --- a/code/model/editableformfields/EditableLiteralField.php +++ b/code/model/editableformfields/EditableLiteralField.php @@ -94,8 +94,7 @@ class EditableLiteralField extends EditableFormField { public function getCMSFields() { $fields = parent::getCMSFields(); - $fields->removeByName('Default'); - $fields->removeByName('Validation'); + $fields->removeByName(array('Default', 'Validation', 'RightTitle')); $fields->addFieldsToTab('Root.Main', array( HTMLEditorField::create('Content', _t('EditableLiteralField.CONTENT', 'HTML')) diff --git a/code/model/editableformfields/EditableNumericField.php b/code/model/editableformfields/EditableNumericField.php index 70f0bef..742bbbe 100755 --- a/code/model/editableformfields/EditableNumericField.php +++ b/code/model/editableformfields/EditableNumericField.php @@ -26,9 +26,13 @@ class EditableNumericField extends EditableFormField { * @return NumericField */ public function getFormField() { - $field = new NumericField($this->Name, $this->EscapedTitle, $this->Default); - $field->addExtraClass('number'); + $field = NumericField::create($this->Name, $this->EscapedTitle, $this->Default) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsField') + ->addExtraClass('number'); + $this->doUpdateFormField($field); + return $field; } diff --git a/code/model/editableformfields/EditableTextField.php b/code/model/editableformfields/EditableTextField.php index 4d21438..384aeae 100755 --- a/code/model/editableformfields/EditableTextField.php +++ b/code/model/editableformfields/EditableTextField.php @@ -65,12 +65,18 @@ class EditableTextField extends EditableFormField { */ public function getFormField() { if($this->Rows > 1) { - $field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default); - $field->setRows($this->Rows); + $field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsTextareaField') + ->setRows($this->Rows); } else { - $field = TextField::create($this->Name, $this->EscapedTitle, $this->Default, $this->MaxLength); + $field = TextField::create($this->Name, $this->EscapedTitle, $this->Default, $this->MaxLength) + ->setFieldHolderTemplate('UserFormsField_holder') + ->setTemplate('UserFormsField'); } + $this->doUpdateFormField($field); + return $field; } diff --git a/css/UserForm.css b/css/UserForm.css index 62413bd..f796879 100644 --- a/css/UserForm.css +++ b/css/UserForm.css @@ -52,9 +52,23 @@ margin-top: 12px; margin-bottom: 12px; } -.userformsgroup legend { +.userformsgroup > legend { padding-left: 4px; padding-right: 4px; border: 0; width: auto; } + +.right-title { + clear: both; + display: block; +} + +.checkbox .right-title { + display: inline; +} + +.left { + margin-bottom: 5px; + font-weight: bold; +} diff --git a/scss/UserForm.scss b/scss/UserForm.scss index 3fa886e..35894c5 100644 --- a/scss/UserForm.scss +++ b/scss/UserForm.scss @@ -64,10 +64,24 @@ margin-top: 12px; margin-bottom: 12px; - legend { + > legend { padding-left: 4px; padding-right: 4px; border: 0; width: auto; } } + +.right-title { + clear: both; + display: block; +} + +.checkbox .right-title { + display: inline; +} + +.left { + margin-bottom: 5px; + font-weight: bold; +} diff --git a/templates/UserFormsDropdownField.ss b/templates/UserFormsDropdownField.ss new file mode 100644 index 0000000..14a1691 --- /dev/null +++ b/templates/UserFormsDropdownField.ss @@ -0,0 +1,5 @@ + diff --git a/templates/UserFormsField.ss b/templates/UserFormsField.ss new file mode 100644 index 0000000..51bfeac --- /dev/null +++ b/templates/UserFormsField.ss @@ -0,0 +1 @@ +aria-describedby="{$Name}_right_title" <% end_if %>/> diff --git a/templates/UserFormsField_holder.ss b/templates/UserFormsField_holder.ss new file mode 100644 index 0000000..9c0c6ff --- /dev/null +++ b/templates/UserFormsField_holder.ss @@ -0,0 +1,8 @@ +