mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
ENHANCEMENT removed needless list from CheckboxGroupField and RadioField
This commit is contained in:
parent
93c25b764f
commit
1b472cda7b
@ -18,8 +18,9 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField
|
||||
|
||||
public function getFormField()
|
||||
{
|
||||
$field = new UserFormsCheckboxSetField($this->Name, $this->EscapedTitle, $this->getOptionsMap());
|
||||
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');
|
||||
$field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
||||
->setFieldHolderTemplate('UserFormsMultipleOptionField_holder')
|
||||
->setTemplate('UserFormsCheckboxSetField');
|
||||
|
||||
// Set the default checked items
|
||||
$defaultCheckedItems = $this->getDefaultOptions();
|
||||
|
@ -28,8 +28,9 @@ class EditableRadioField extends EditableMultipleOptionField
|
||||
|
||||
public function getFormField()
|
||||
{
|
||||
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
|
||||
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');
|
||||
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
||||
->setFieldHolderTemplate('UserFormsMultipleOptionField_holder')
|
||||
->setTemplate('UserFormsOptionSetField');
|
||||
|
||||
// Set default item
|
||||
$defaultOption = $this->getDefaultOptions()->first();
|
||||
|
7
templates/UserFormsOptionSetField.ss
Normal file
7
templates/UserFormsOptionSetField.ss
Normal file
@ -0,0 +1,7 @@
|
||||
<% loop $Options %>
|
||||
<div class="$Class">
|
||||
<input id="$ID" class="radio" name="$Name" type="radio" value="$Value.ATT"<% if $isChecked %>
|
||||
checked<% end_if %><% if $isDisabled %> disabled<% end_if %> <% if $Up.Required %>required<% end_if %> />
|
||||
<label for="$ID">$Title</label>
|
||||
</div>
|
||||
<% end_loop %>
|
11
templates/forms/UserFormsCheckboxSetField.ss
Normal file
11
templates/forms/UserFormsCheckboxSetField.ss
Normal file
@ -0,0 +1,11 @@
|
||||
<% if $Options.Count %>
|
||||
<% loop $Options %>
|
||||
<div class="$Class">
|
||||
<input id="$ID" class="checkbox" name="$Name" type="checkbox" value="$Value.ATT"<% if $isChecked %>
|
||||
checked="checked"<% end_if %><% if $isDisabled %> disabled="disabled"<% end_if %> />
|
||||
<label for="$ID">$Title</label>
|
||||
</div>
|
||||
<% end_loop %>
|
||||
<% else %>
|
||||
<p>No options available</p>
|
||||
<% end_if %>
|
15
tests/EditableCheckboxGroupFieldTest.php
Normal file
15
tests/EditableCheckboxGroupFieldTest.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class EditableCheckboxGroupFieldTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
||||
|
||||
/**
|
||||
* Tests that this element is rendered with a custom template
|
||||
*/
|
||||
public function testRenderedWithCustomTemplate()
|
||||
{
|
||||
$checkboxGroup = $this->objFromFixture('EditableCheckboxGroupField', 'checkbox-group');
|
||||
$this->assertEquals('UserFormsCheckboxSetField', $checkboxGroup->getFormField()->getTemplate());
|
||||
}
|
||||
}
|
15
tests/EditableRadioFieldTest.php
Normal file
15
tests/EditableRadioFieldTest.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class EditableRadioFieldTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
||||
|
||||
/**
|
||||
* Tests that this element is rendered with a custom template
|
||||
*/
|
||||
public function testRenderedWithCustomTemplate()
|
||||
{
|
||||
$radio = $this->objFromFixture('EditableRadioField', 'radio-field');
|
||||
$this->assertEquals('UserFormsOptionSetField', $radio->getFormField()->getTemplate());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user