2008-09-29 03:18:23 +00:00
< ? php
/**
* EditableCheckbox
2012-04-14 18:36:50 +12:00
*
2008-09-29 03:18:23 +00:00
* A user modifiable checkbox on a UserDefinedForm
2009-04-17 02:26:40 +00:00
*
* @ package userforms
2008-09-29 03:18:23 +00:00
*/
2009-12-07 02:04:20 +00:00
2008-09-29 03:18:23 +00:00
class EditableCheckbox extends EditableFormField {
2013-04-02 18:34:43 -07:00
private static $singular_name = 'Checkbox Field' ;
2008-09-29 03:18:23 +00:00
2013-04-02 18:34:43 -07:00
private static $plural_name = 'Checkboxes' ;
2008-09-29 03:18:23 +00:00
2009-05-06 03:34:40 +00:00
public function getFieldConfiguration () {
$options = parent :: getFieldConfiguration ();
$options -> push ( new CheckboxField ( " Fields[ $this->ID ][CustomSettings][Default] " , _t ( 'EditableFormField.CHECKEDBYDEFAULT' , 'Checked by Default?' ), $this -> getSetting ( 'Default' )));
2012-04-14 18:36:50 +12:00
2009-05-06 03:34:40 +00:00
return $options ;
2008-09-29 03:18:23 +00:00
}
2009-04-27 06:00:05 +00:00
public function getFormField () {
return new CheckboxField ( $this -> Name , $this -> Title , $this -> getSetting ( 'Default' ));
2008-09-29 03:18:23 +00:00
}
2009-05-06 03:34:40 +00:00
public function getValueFromData ( $data ) {
$value = ( isset ( $data [ $this -> Name ])) ? $data [ $this -> Name ] : false ;
2010-09-08 03:20:28 +00:00
2009-05-06 03:34:40 +00:00
return ( $value ) ? _t ( 'EditableFormField.YES' , 'Yes' ) : _t ( 'EditableFormField.NO' , 'No' );
}
2009-12-07 02:04:20 +00:00
}