mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-01 15:28:02 +02:00
Fixed some whitespace git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47725 467b73ca-7a2a-4603-9d3b-597d59a354a9
49 lines
1.2 KiB
PHP
Executable File
49 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage forms
|
|
*/
|
|
|
|
/**
|
|
* EditableCheckbox
|
|
* A user modifiable checkbox on a UserDefinedForm
|
|
*/
|
|
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 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' )
|
|
);
|
|
}
|
|
}
|
|
?>
|