MINOR: refactored EditableCheckboxField to use custom settings field

This commit is contained in:
Will Rossiter 2009-04-25 02:54:10 +00:00
parent 058f606f48
commit c136fa4cc4

View File

@ -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() {