2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2008-01-08 07:37:50 +01:00
|
|
|
|
|
|
|
/**
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fieldeditor
|
2008-01-08 07:37:50 +01:00
|
|
|
*/
|
|
|
|
|
2008-01-09 05:18:36 +01:00
|
|
|
/**
|
|
|
|
* EditableCheckbox
|
|
|
|
* A user modifiable checkbox on a UserDefinedForm
|
|
|
|
* @package forms
|
|
|
|
* @subpackage fieldeditor
|
|
|
|
*/
|
|
|
|
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'));
|
2007-07-19 12:40:28 +02:00
|
|
|
|
2008-01-09 05:18:36 +01:00
|
|
|
if( $this->readonly )
|
|
|
|
$checkbox = $checkbox->performReadonlyTransformation();
|
2007-07-19 12:40:28 +02:00
|
|
|
|
2008-01-09 05:18:36 +01:00
|
|
|
return $checkbox->FieldHolder();
|
|
|
|
}
|
|
|
|
|
|
|
|
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') );
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilterField() {
|
|
|
|
return new OptionsetField( $this->Name,
|
|
|
|
$this->Title,
|
|
|
|
array( '-1' => '(Any)',
|
|
|
|
'on' => 'Selected',
|
|
|
|
'0' => 'Not selected' )
|
|
|
|
);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2008-01-09 05:18:36 +01:00
|
|
|
}
|
2007-07-19 12:40:28 +02:00
|
|
|
?>
|