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,11 +1,13 @@
|
||||
<div class="form-group selection-group">
|
||||
<ul class="form__field-holder form__field-holder--no-label SelectionGroup<% if $extraClass %> $extraClass<% end_if %>">
|
||||
<ul>
|
||||
<% if $IsReadonly %>
|
||||
<% loop $FieldSet %>
|
||||
<% if $Selected %>
|
||||
<li class="selected selection-group__item">
|
||||
$RadioLabel
|
||||
$SmallFieldHolder
|
||||
<%-- Bypass composite item field and directly render child fields --%>
|
||||
<% loop $FieldList %>
|
||||
$Field
|
||||
<% end_loop %>
|
||||
</li>
|
||||
<% end_if %>
|
||||
<% end_loop %>
|
||||
@ -13,9 +15,11 @@
|
||||
<% loop $FieldSet %>
|
||||
<li class="selection-group__item<% if $Selected %> selected<% end_if %>">
|
||||
{$RadioButton}{$RadioLabel}
|
||||
$SmallFieldHolder
|
||||
<%-- Bypass composite item field and directly render child fields --%>
|
||||
<% loop $FieldList %>
|
||||
$Field
|
||||
<% end_loop %>
|
||||
</li>
|
||||
<% end_loop %>
|
||||
<% end_if %>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -82,6 +82,7 @@ class SelectionGroup extends CompositeField {
|
||||
}
|
||||
|
||||
$itemID = $this->ID() . '_' . (++$count);
|
||||
// @todo Move into SelectionGroup_Item.ss template at some point.
|
||||
$extra = array(
|
||||
"RadioButton" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
||||
'input',
|
||||
@ -91,12 +92,16 @@ class SelectionGroup extends CompositeField {
|
||||
'id' => $itemID,
|
||||
'name' => $this->name,
|
||||
'value' => $item->getValue(),
|
||||
'checked' => $checked
|
||||
'checked' => $checked,
|
||||
'aria-labelledby' => "title-{$itemID}",
|
||||
)
|
||||
)),
|
||||
"RadioLabel" => DBField::create_field('HTMLFragment', FormField::create_tag(
|
||||
'label',
|
||||
array('for' => $itemID),
|
||||
array(
|
||||
'id' => "title-{$itemID}",
|
||||
'for' => $itemID
|
||||
),
|
||||
$item->getTitle()
|
||||
)),
|
||||
"Selected" => $firstSelected,
|
||||
@ -116,9 +121,7 @@ class SelectionGroup extends CompositeField {
|
||||
Requirements::javascript(FRAMEWORK_DIR . '/client/dist/js/SelectionGroup.js');
|
||||
Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/SelectionGroup.css');
|
||||
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
|
||||
return $obj->renderWith($this->getTemplates());
|
||||
return parent::FieldHolder($properties);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,3 @@
|
||||
<$Tag class="CompositeField $extraClass <% if ColumnCount %>multicolumn<% end_if %>">
|
||||
<% if $Tag == 'fieldset' && $Legend %>
|
||||
<legend>$Legend</legend>
|
||||
<% end_if %>
|
||||
|
||||
<% loop $FieldList %>
|
||||
<% if $ColumnCount %>
|
||||
<div class="column-{$ColumnCount} $FirstLast">
|
||||
@ -12,4 +7,3 @@
|
||||
$Field
|
||||
<% end_if %>
|
||||
<% end_loop %>
|
||||
</$Tag>
|
||||
|
@ -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 %>
|
||||
<legend>$Legend</legend>
|
||||
<% end_if %>
|
||||
|
||||
<% loop $FieldList %>
|
||||
<% if $ColumnCount %>
|
||||
<div class="column-{$ColumnCount} $FirstLast">
|
||||
$FieldHolder
|
||||
</div>
|
||||
<% else %>
|
||||
$FieldHolder
|
||||
<% end_if %>
|
||||
<% end_loop %>
|
||||
|
||||
<% if $Description %><span class="description">$Description</span><% end_if %>
|
||||
$Field
|
||||
</$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 %>
|
||||
<legend>$Legend</legend>
|
||||
<% end_if %>
|
||||
|
Loading…
Reference in New Issue
Block a user