mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
MINOR: refactored EditableCheckboxField to use custom settings field
This commit is contained in:
parent
058f606f48
commit
c136fa4cc4
@ -7,30 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
class EditableCheckbox extends EditableFormField {
|
class EditableCheckbox extends EditableFormField {
|
||||||
|
|
||||||
// Could remove this and just use value
|
|
||||||
static $db = array(
|
|
||||||
"Checked" => "Boolean"
|
|
||||||
);
|
|
||||||
|
|
||||||
static $singular_name = 'Checkbox';
|
static $singular_name = 'Checkbox';
|
||||||
|
|
||||||
static $plural_name = 'Checkboxes';
|
static $plural_name = 'Checkboxes';
|
||||||
|
|
||||||
function CheckboxField() {
|
function ExtraOptions() {
|
||||||
$checkbox = new CheckboxField("Fields[".$this->ID."][Default]", "Checked by default", $this->getField('Default'));
|
$fields = new FieldSet(
|
||||||
|
new CheckboxField("Fields[$this->ID][CustomSettings][Default]", _t('EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?'), $this->getSetting('Default'))
|
||||||
if( $this->readonly )
|
);
|
||||||
$checkbox = $checkbox->performReadonlyTransformation();
|
$fields->merge(parent::ExtraOptions());
|
||||||
|
return $fields;
|
||||||
return $checkbox->FieldHolder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateFromPostData( $data ) {
|
|
||||||
$this->setField('Checked', isset($data['Checked']) ? $data['Checked'] : null);
|
|
||||||
parent::populateFromPostData( $data );
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFormField() {
|
function getFormField() {
|
||||||
return new CheckboxField( $this->Name, $this->Title, $this->getField('Default') );
|
return new CheckboxField( $this->Name, $this->Title, $this->getSetting('Default'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilterField() {
|
function getFilterField() {
|
||||||
|
Loading…
Reference in New Issue
Block a user