mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix invalid markup in SelectionGroup selected values
This commit is contained in:
parent
625f7b4eee
commit
2512761587
@ -2,7 +2,7 @@
|
||||
<ul class="SelectionGroup<% if extraClass %> $extraClass<% end_if %>">
|
||||
<% loop $FieldSet %>
|
||||
<% if $Selected %>
|
||||
<li$Selected>
|
||||
<li class="selected">
|
||||
$RadioLabel
|
||||
$FieldHolder
|
||||
</li>
|
||||
@ -12,7 +12,7 @@
|
||||
<% else %>
|
||||
<ul class="SelectionGroup<% if extraClass %> $extraClass<% end_if %>">
|
||||
<% loop $FieldSet %>
|
||||
<li$Selected>
|
||||
<li <% if Selected %>class="selected"<% end_if %>>
|
||||
<label>{$RadioButton} {$RadioLabel}</label>
|
||||
<% if $FieldList %>
|
||||
$FieldHolder
|
||||
|
@ -41,6 +41,33 @@ class SelectionGroupTest extends SapphireTest
|
||||
$this->assertContains('two view', (string)$listElTwo->div);
|
||||
}
|
||||
|
||||
function testSelectedFieldHolder()
|
||||
{
|
||||
$items = array(
|
||||
new SelectionGroup_Item(
|
||||
'one',
|
||||
new LiteralField('one', 'one view'),
|
||||
'one title'
|
||||
),
|
||||
new SelectionGroup_Item(
|
||||
'two',
|
||||
new LiteralField('two', 'two view'),
|
||||
'two title'
|
||||
),
|
||||
);
|
||||
$field = new SelectionGroup('MyGroup', $items);
|
||||
$field->setValue('two');
|
||||
|
||||
$parser = new CSSContentParser($field->FieldHolder());
|
||||
$listEls = $parser->getBySelector('li');
|
||||
$listElOne = $listEls[0];
|
||||
$listElTwo = $listEls[1];
|
||||
|
||||
$this->assertEquals('one', (string)$listElOne->label[0]->input[0]['value']);
|
||||
$this->assertEquals('two', (string)$listElTwo->label[0]->input[0]['value']);
|
||||
$this->assertEquals('selected', (string)$listElTwo->attributes()->class);
|
||||
}
|
||||
|
||||
function testLegacyItemsFieldHolder()
|
||||
{
|
||||
$items = array(
|
||||
|
Loading…
Reference in New Issue
Block a user