mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Update core templates for CompositeField / SelectionGroup.ss
This commit is contained in:
parent
7a095b1a70
commit
c556b01071
6
admin/themes/cms-forms/templates/forms/CompositeField.ss
Normal file
6
admin/themes/cms-forms/templates/forms/CompositeField.ss
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<% if $Tag == 'fieldset' && $Legend %>
|
||||||
|
<legend>$Legend</legend>
|
||||||
|
<% end_if %>
|
||||||
|
<% loop $FieldList %>
|
||||||
|
$FieldHolder
|
||||||
|
<% end_loop %>
|
@ -0,0 +1,17 @@
|
|||||||
|
<div id="$HolderID" class="form-group field<% if $extraClass %> $extraClass<% end_if %>">
|
||||||
|
<% if $Title %>
|
||||||
|
<label for="$ID" id="title-$ID" class="form__field-label">$Title</label>
|
||||||
|
<% end_if %>
|
||||||
|
<$Tag id="$ID" <% include AriaAttributes %>
|
||||||
|
class="form__fieldgroup form__field-holder
|
||||||
|
<% if not $Title %> form__field-holder--no-label<% end_if %>
|
||||||
|
<% if $Zebra %> form__fieldgroup-zebra<% end_if %>
|
||||||
|
<% if $extraClass %> $extraClass<% end_if %>"
|
||||||
|
>
|
||||||
|
$Field
|
||||||
|
<%-- TODO: change $MessageType to match Bootstraps alert types, e.g. alert-info, alert-danger etc --%>
|
||||||
|
<% if $Message %><p class="alert $MessageType" role="alert" id="message-$ID">$Message</p><% end_if %>
|
||||||
|
<% if $Description %><p class="form__field-description" id="describes-$ID">$Description</p><% end_if %>
|
||||||
|
</$Tag>
|
||||||
|
<% if $RightTitle %><p class="form__field-extra-label" id="extra-label-$ID">$RightTitle</p><% end_if %>
|
||||||
|
</div>
|
@ -0,0 +1,17 @@
|
|||||||
|
<div id="$HolderID" class="form__fieldgroup-item field field--small<% if $extraClass %> $extraClass<% end_if %>">
|
||||||
|
<% if $Title %>
|
||||||
|
<label for="$ID" id="title-$ID" class="form__fieldgroup-label">$Title</label>
|
||||||
|
<% end_if %>
|
||||||
|
<$Tag id="$ID"
|
||||||
|
<% if $Title %>aria-labelledby="title-$ID"<% end_if %>
|
||||||
|
class="form__fieldgroup form__field-holder
|
||||||
|
<% if not $Title %> form__field-holder--no-label<% end_if %>
|
||||||
|
<% if $Zebra %> form__fieldgroup-zebra<% end_if %>
|
||||||
|
<% if $extraClass %> $extraClass<% end_if %>"
|
||||||
|
>
|
||||||
|
<%-- Note: _holder_small.ss overrides CompositeField.ss to force nested $SmallFieldHolder --%>
|
||||||
|
<% loop $FieldList %>
|
||||||
|
$SmallFieldHolder
|
||||||
|
<% end_loop %>
|
||||||
|
</$Tag>
|
||||||
|
</div>
|
@ -1,21 +1,25 @@
|
|||||||
<div class="form-group selection-group">
|
<ul>
|
||||||
<ul class="form__field-holder form__field-holder--no-label SelectionGroup<% if $extraClass %> $extraClass<% end_if %>">
|
<% if $IsReadonly %>
|
||||||
<% if $IsReadonly %>
|
<% loop $FieldSet %>
|
||||||
<% loop $FieldSet %>
|
<% if $Selected %>
|
||||||
<% if $Selected %>
|
<li class="selected selection-group__item">
|
||||||
<li class="selected selection-group__item">
|
$RadioLabel
|
||||||
$RadioLabel
|
<%-- Bypass composite item field and directly render child fields --%>
|
||||||
$SmallFieldHolder
|
<% loop $FieldList %>
|
||||||
</li>
|
$Field
|
||||||
<% end_if %>
|
<% end_loop %>
|
||||||
<% end_loop %>
|
|
||||||
<% else %>
|
|
||||||
<% loop $FieldSet %>
|
|
||||||
<li class="selection-group__item<% if $Selected %> selected<% end_if %>">
|
|
||||||
{$RadioButton}{$RadioLabel}
|
|
||||||
$SmallFieldHolder
|
|
||||||
</li>
|
</li>
|
||||||
<% end_loop %>
|
<% end_if %>
|
||||||
<% end_if %>
|
<% end_loop %>
|
||||||
</ul>
|
<% else %>
|
||||||
</div>
|
<% loop $FieldSet %>
|
||||||
|
<li class="selection-group__item<% if $Selected %> selected<% end_if %>">
|
||||||
|
{$RadioButton}{$RadioLabel}
|
||||||
|
<%-- Bypass composite item field and directly render child fields --%>
|
||||||
|
<% loop $FieldList %>
|
||||||
|
$Field
|
||||||
|
<% end_loop %>
|
||||||
|
</li>
|
||||||
|
<% end_loop %>
|
||||||
|
<% end_if %>
|
||||||
|
</ul>
|
||||||
|
@ -82,6 +82,7 @@ class SelectionGroup extends CompositeField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$itemID = $this->ID() . '_' . (++$count);
|
$itemID = $this->ID() . '_' . (++$count);
|
||||||
|
// @todo Move into SelectionGroup_Item.ss template at some point.
|
||||||
$extra = array(
|
$extra = array(
|
||||||
"RadioButton" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
"RadioButton" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
||||||
'input',
|
'input',
|
||||||
@ -91,12 +92,16 @@ class SelectionGroup extends CompositeField {
|
|||||||
'id' => $itemID,
|
'id' => $itemID,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'value' => $item->getValue(),
|
'value' => $item->getValue(),
|
||||||
'checked' => $checked
|
'checked' => $checked,
|
||||||
|
'aria-labelledby' => "title-{$itemID}",
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
"RadioLabel" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
"RadioLabel" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
||||||
'label',
|
'label',
|
||||||
array('for' => $itemID),
|
array(
|
||||||
|
'id' => "title-{$itemID}",
|
||||||
|
'for' => $itemID
|
||||||
|
),
|
||||||
$item->getTitle()
|
$item->getTitle()
|
||||||
)),
|
)),
|
||||||
"Selected" => $firstSelected,
|
"Selected" => $firstSelected,
|
||||||
@ -116,9 +121,7 @@ class SelectionGroup extends CompositeField {
|
|||||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/SelectionGroup.js');
|
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/SelectionGroup.js');
|
||||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/SelectionGroup.css');
|
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/SelectionGroup.css');
|
||||||
|
|
||||||
$obj = $properties ? $this->customise($properties) : $this;
|
return parent::FieldHolder($properties);
|
||||||
|
|
||||||
return $obj->renderWith($this->getTemplates());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
<$Tag class="CompositeField $extraClass <% if ColumnCount %>multicolumn<% end_if %>">
|
<% loop $FieldList %>
|
||||||
<% if $Tag == 'fieldset' && $Legend %>
|
<% if $ColumnCount %>
|
||||||
<legend>$Legend</legend>
|
<div class="column-{$ColumnCount} $FirstLast">
|
||||||
<% end_if %>
|
|
||||||
|
|
||||||
<% loop $FieldList %>
|
|
||||||
<% if $ColumnCount %>
|
|
||||||
<div class="column-{$ColumnCount} $FirstLast">
|
|
||||||
$Field
|
|
||||||
</div>
|
|
||||||
<% else %>
|
|
||||||
$Field
|
$Field
|
||||||
<% end_if %>
|
</div>
|
||||||
<% end_loop %>
|
<% else %>
|
||||||
</$Tag>
|
$Field
|
||||||
|
<% end_if %>
|
||||||
|
<% end_loop %>
|
||||||
|
@ -1,17 +1,7 @@
|
|||||||
<$Tag class="CompositeField $extraClass <% if ColumnCount %>multicolumn<% end_if %>" id="$HolderID">
|
<$Tag class="CompositeField $extraClass <% if $ColumnCount %>multicolumn<% end_if %>" id="$HolderID">
|
||||||
<% if $Tag == 'fieldset' && $Legend %>
|
<% if $Tag == 'fieldset' && $Legend %>
|
||||||
<legend>$Legend</legend>
|
<legend>$Legend</legend>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% loop $FieldList %>
|
$Field
|
||||||
<% if $ColumnCount %>
|
|
||||||
<div class="column-{$ColumnCount} $FirstLast">
|
|
||||||
$FieldHolder
|
|
||||||
</div>
|
|
||||||
<% else %>
|
|
||||||
$FieldHolder
|
|
||||||
<% end_if %>
|
|
||||||
<% end_loop %>
|
|
||||||
|
|
||||||
<% if $Description %><span class="description">$Description</span><% end_if %>
|
|
||||||
</$Tag>
|
</$Tag>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<$Tag class="CompositeField $extraClass <% if $ColumnCount %>multicolumn<% end_if %>">
|
<$Tag class="CompositeField $extraClass <% if $ColumnCount %>multicolumn<% end_if %>" id="$HolderID">
|
||||||
<% if $Tag == 'fieldset' && $Legend %>
|
<% if $Tag == 'fieldset' && $Legend %>
|
||||||
<legend>$Legend</legend>
|
<legend>$Legend</legend>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
Loading…
Reference in New Issue
Block a user