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 {
|
||||
|
||||
// Could remove this and just use value
|
||||
static $db = array(
|
||||
"Checked" => "Boolean"
|
||||
);
|
||||
|
||||
static $singular_name = 'Checkbox';
|
||||
|
||||
static $plural_name = 'Checkboxes';
|
||||
|
||||
function CheckboxField() {
|
||||
$checkbox = new CheckboxField("Fields[".$this->ID."][Default]", "Checked by default", $this->getField('Default'));
|
||||
|
||||
if( $this->readonly )
|
||||
$checkbox = $checkbox->performReadonlyTransformation();
|
||||
|
||||
return $checkbox->FieldHolder();
|
||||
function ExtraOptions() {
|
||||
$fields = new FieldSet(
|
||||
new CheckboxField("Fields[$this->ID][CustomSettings][Default]", _t('EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?'), $this->getSetting('Default'))
|
||||
);
|
||||
$fields->merge(parent::ExtraOptions());
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function populateFromPostData( $data ) {
|
||||
$this->setField('Checked', isset($data['Checked']) ? $data['Checked'] : null);
|
||||
parent::populateFromPostData( $data );
|
||||
}
|
||||
|
||||
function getFormField() {
|
||||
return new CheckboxField( $this->Name, $this->Title, $this->getField('Default') );
|
||||
return new CheckboxField( $this->Name, $this->Title, $this->getSetting('Default'));
|
||||
}
|
||||
|
||||
function getFilterField() {
|
||||
|
Loading…
Reference in New Issue
Block a user