Merge pull request #310 from flashbackzoo/pulls/update-right-title

Consistant treatment of field's right title
This commit is contained in:
Christopher Pitt 2015-08-21 15:47:58 +12:00
commit a250fa3171
23 changed files with 108 additions and 37 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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(

View File

@ -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',

View File

@ -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;
}

View File

@ -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'))

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View 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>

View File

@ -0,0 +1 @@
<input $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>/>

View 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>

View 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 %>/>

View File

@ -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 %>
<legend>$Legend</legend>
<% end_if %>
@ -15,11 +15,5 @@
<% end_loop %>
</div>
<% if $RightTitle %>
<aside class="right" role="complementary">
<p>$RightTitle</p>
</aside>
<% end_if %>
<% if $Description %><span class="description">$Description</span><% end_if %>
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
</$Tag>

View File

@ -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 %>
<div class="middleColumn">
$Field
</div>
<% if $RightTitle %>
<aside class="right" role="complementary">
<p>$RightTitle</p>
</aside>
<% end_if %>
<% if $RightTitle %><span id="{$Name}_right_title" class="right-title">$RightTitle</span><% end_if %>
<% if $Message %><span class="message $MessageType">$Message</span><% end_if %>
<% if $Description %><span class="description">$Description</span><% end_if %>
</fieldset>

View File

@ -0,0 +1 @@
<textarea $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>>$Value</textarea>

View 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 %>

View 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>