mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Consistant treatment of field's right title
This commit is contained in:
parent
52072d44eb
commit
e9ef2a03aa
@ -32,8 +32,12 @@ class EditableCheckbox extends EditableFormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField() {
|
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);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
@ -23,8 +23,12 @@ class EditableCountryDropdownField extends EditableFormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField() {
|
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);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,14 @@ class EditableDateField extends EditableFormField {
|
|||||||
$defaultValue = $this->DefaultToToday
|
$defaultValue = $this->DefaultToToday
|
||||||
? SS_Datetime::now()->Format('Y-m-d')
|
? SS_Datetime::now()->Format('Y-m-d')
|
||||||
: $this->Default;
|
: $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);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ class EditableDropdown extends EditableMultipleOptionField {
|
|||||||
* @return DropdownField
|
* @return DropdownField
|
||||||
*/
|
*/
|
||||||
public function getFormField() {
|
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
|
// Set default
|
||||||
$defaultOption = $this->getDefaultOptions()->first();
|
$defaultOption = $this->getDefaultOptions()->first();
|
||||||
|
@ -18,8 +18,12 @@ class EditableEmailField extends EditableFormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField() {
|
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);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ class EditableFieldGroup extends EditableFormField {
|
|||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$field = UserFormsGroupField::create()
|
$field = UserFormsGroupField::create()
|
||||||
->setTitle($this->EscapedTitle ?: false);
|
->setTitle($this->EscapedTitle ?: false)
|
||||||
|
->setName($this->Name);
|
||||||
$this->doUpdateFormField($field);
|
$this->doUpdateFormField($field);
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@ class EditableFileField extends EditableFormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField() {
|
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
|
// filter out '' since this would be a regex problem on JS end
|
||||||
$field->getValidator()->setAllowedExtensions(
|
$field->getValidator()->setAllowedExtensions(
|
||||||
|
@ -29,8 +29,7 @@ class EditableFormHeading extends EditableFormField {
|
|||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
$fields->removeByName(array('Default', 'Validation', 'RightTitle'));
|
||||||
$fields->removeByName('Validation');
|
|
||||||
|
|
||||||
$levels = array(
|
$levels = array(
|
||||||
'1' => '1',
|
'1' => '1',
|
||||||
|
@ -24,7 +24,7 @@ class EditableFormStep extends EditableFormField {
|
|||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->removeByName(array('MergeField', 'Default', 'Validation'));
|
$fields->removeByName(array('MergeField', 'Default', 'Validation', 'RightTitle'));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,7 @@ class EditableLiteralField extends EditableFormField {
|
|||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
$fields->removeByName(array('Default', 'Validation', 'RightTitle'));
|
||||||
$fields->removeByName('Validation');
|
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Main', array(
|
$fields->addFieldsToTab('Root.Main', array(
|
||||||
HTMLEditorField::create('Content', _t('EditableLiteralField.CONTENT', 'HTML'))
|
HTMLEditorField::create('Content', _t('EditableLiteralField.CONTENT', 'HTML'))
|
||||||
|
@ -26,9 +26,13 @@ class EditableNumericField extends EditableFormField {
|
|||||||
* @return NumericField
|
* @return NumericField
|
||||||
*/
|
*/
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$field = new NumericField($this->Name, $this->EscapedTitle, $this->Default);
|
$field = NumericField::create($this->Name, $this->EscapedTitle, $this->Default)
|
||||||
$field->addExtraClass('number');
|
->setFieldHolderTemplate('UserFormsField_holder')
|
||||||
|
->setTemplate('UserFormsField')
|
||||||
|
->addExtraClass('number');
|
||||||
|
|
||||||
$this->doUpdateFormField($field);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,12 +65,18 @@ class EditableTextField extends EditableFormField {
|
|||||||
*/
|
*/
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
if($this->Rows > 1) {
|
if($this->Rows > 1) {
|
||||||
$field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default);
|
$field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default)
|
||||||
$field->setRows($this->Rows);
|
->setFieldHolderTemplate('UserFormsField_holder')
|
||||||
|
->setTemplate('UserFormsTextareaField')
|
||||||
|
->setRows($this->Rows);
|
||||||
} else {
|
} 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);
|
$this->doUpdateFormField($field);
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,23 @@
|
|||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
.userformsgroup legend {
|
.userformsgroup > legend {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
padding-right: 4px;
|
padding-right: 4px;
|
||||||
border: 0;
|
border: 0;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right-title {
|
||||||
|
clear: both;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox .right-title {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
@ -64,10 +64,24 @@
|
|||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
|
||||||
legend {
|
> legend {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
padding-right: 4px;
|
padding-right: 4px;
|
||||||
border: 0;
|
border: 0;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right-title {
|
||||||
|
clear: both;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox .right-title {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
5
templates/UserFormsDropdownField.ss
Normal file
5
templates/UserFormsDropdownField.ss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<select $AttributesHTML <% if $RightTitle %>aria-describedby="{$Name}_right_title"<% end_if %>>
|
||||||
|
<% loop $Options %>
|
||||||
|
<option value="$Value.XML"<% if $Selected %> selected="selected"<% end_if %><% if $Disabled %> disabled="disabled"<% end_if %>>$Title.XML</option>
|
||||||
|
<% end_loop %>
|
||||||
|
</select>
|
1
templates/UserFormsField.ss
Normal file
1
templates/UserFormsField.ss
Normal file
@ -0,0 +1 @@
|
|||||||
|
<input $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>/>
|
8
templates/UserFormsField_holder.ss
Normal file
8
templates/UserFormsField_holder.ss
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<div id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>">
|
||||||
|
<% if $Title %><label class="left" for="$ID">$Title</label><% end_if %>
|
||||||
|
<div class="middleColumn">
|
||||||
|
$Field
|
||||||
|
</div>
|
||||||
|
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
|
||||||
|
<% if $Message %><span class="message $MessageType">$Message</span><% end_if %>
|
||||||
|
</div>
|
2
templates/UserFormsFileField.ss
Normal file
2
templates/UserFormsFileField.ss
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<input type="hidden" name="MAX_FILE_SIZE" value="$MaxFileSize" />
|
||||||
|
<input $AttributesHTML<% if $RightTitle %> aria-describedby="{$Name}_right_title"<% end_if %>/>
|
@ -1,4 +1,4 @@
|
|||||||
<$Tag class="CompositeField $extraClass <% if ColumnCount %>multicolumn<% end_if %>">
|
<$Tag class="CompositeField $extraClass <% if ColumnCount %>multicolumn<% end_if %>"<% if $Tag == 'fieldset' && $RightTitle %>aria-describedby="{$Name}_right_title"<% end_if %>>
|
||||||
<% if $Tag == 'fieldset' && $Legend %>
|
<% if $Tag == 'fieldset' && $Legend %>
|
||||||
<legend>$Legend</legend>
|
<legend>$Legend</legend>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
@ -15,11 +15,5 @@
|
|||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if $RightTitle %>
|
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
|
||||||
<aside class="right" role="complementary">
|
|
||||||
<p>$RightTitle</p>
|
|
||||||
</aside>
|
|
||||||
<% end_if %>
|
|
||||||
|
|
||||||
<% if $Description %><span class="description">$Description</span><% end_if %>
|
|
||||||
</$Tag>
|
</$Tag>
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
<fieldset id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>">
|
<fieldset id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>"<% if $RightTitle %> aria-describedby="{$Name}_right_title"<% end_if %>>
|
||||||
<% if $Title %><legend class="left">$Title</legend><% end_if %>
|
<% if $Title %><legend class="left">$Title</legend><% end_if %>
|
||||||
|
|
||||||
<div class="middleColumn">
|
<div class="middleColumn">
|
||||||
$Field
|
$Field
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if $RightTitle %>
|
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
|
||||||
<aside class="right" role="complementary">
|
|
||||||
<p>$RightTitle</p>
|
|
||||||
</aside>
|
|
||||||
<% end_if %>
|
|
||||||
|
|
||||||
<% if $Message %><span class="message $MessageType">$Message</span><% end_if %>
|
<% if $Message %><span class="message $MessageType">$Message</span><% end_if %>
|
||||||
|
|
||||||
<% if $Description %><span class="description">$Description</span><% end_if %>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
1
templates/UserFormsTextareaField.ss
Normal file
1
templates/UserFormsTextareaField.ss
Normal file
@ -0,0 +1 @@
|
|||||||
|
<textarea $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>>$Value</textarea>
|
2
templates/UserformsCheckboxField.ss
Normal file
2
templates/UserformsCheckboxField.ss
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<input $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>/>
|
||||||
|
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
|
7
templates/UserformsCheckboxField_holder.ss
Normal file
7
templates/UserformsCheckboxField_holder.ss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>">
|
||||||
|
<% if $Title %><label class="left" for="$ID">$Title</label><% end_if %>
|
||||||
|
<div class="middleColumn">
|
||||||
|
$Field
|
||||||
|
</div>
|
||||||
|
<% if $Message %><span class="message $MessageType">$Message</span><% end_if %>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user