Php SelectionGroup未添加额外属性
我有PHP代码:Php SelectionGroup未添加额外属性,php,silverstripe,Php,Silverstripe,我有PHP代码: SelectionGroup::create( //... SelectionGroup_Item::create(/*...*/), SelectionGroup_Item::create(/*...*/), //... ) ->addExtraClass("some-extra-class") ->setAttribute('ng-change','log(myModel)') ->setAttribute('ng-model','myModel') 呈
SelectionGroup::create(
//...
SelectionGroup_Item::create(/*...*/),
SelectionGroup_Item::create(/*...*/),
//...
)
->addExtraClass("some-extra-class")
->setAttribute('ng-change','log(myModel)')
->setAttribute('ng-model','myModel')
呈现的html如下所示:
...
<ul class="SelectionGroup field CompositeField selectiongroup some-extra-class nolabel">
...
</ul>
...
呈现以下HTML:
...
<input type="hidden" ... does="this work" />
<ul class="SelectionGroup field CompositeField selectiongroup some-extra-class nolabel">
...
<input type="hidden" ... maybe="it does" />
...
</ul>
...
。。。
...
...
...
在SilverStripe 3.4中,SelectionGroup\u Item
使用的默认模板中未调用$attributestml
变量
SelectionGroup\u项
使用CompositeField
模板(因为它在框架中没有自己的模板设置)
框架中当前的复合字段
模板在开始标记中不包括$attributestml
:
<$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">
$Field
</div>
<% else %>
$Field
<% end_if %>
<% end_loop %>
</$Tag>
创建此模板后,我们需要在页面URL中调用
?flush=all
,以便系统清除其缓存并找到此新模板。您使用的是哪个版本的SS?@RobbieAverill 3.4(稳定)很遗憾,我认为这会在默认情况下实现。。。我想在任何地方都很难实现一切
<$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">
$Field
</div>
<% else %>
$Field
<% end_if %>
<% end_loop %>
</$Tag>
<$Tag $AttributesHTML 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">
$Field
</div>
<% else %>
$Field
<% end_if %>
<% end_loop %>
</$Tag>