• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List

system/controls/formcontrolcheckbox.php

00001 <?php
00002 
00003 namespace Habari;
00004 
00008 class FormControlCheckbox extends FormControl
00009 {
00010   public $returned_value;
00011 
00015   public function _extend()
00016   {
00017     $this->properties['type'] = 'checkbox';
00018     $this->settings['internal_value'] = true;
00019     $this->returned_value = true;
00020   }
00021 
00027   public function get(Theme $theme)
00028   {
00029     // Because this is a checkbox, the value isn't directly output in the control
00030     $this->properties['value'] = $this->returned_value;
00031     if($this->value == false) {
00032       unset($this->properties['checked']);
00033     }
00034     else {
00035       $this->properties['checked'] = 'checked';
00036     }
00037     return parent::get($theme);
00038   }
00039 
00043   public function process()
00044   {
00045     if(isset($_POST[$this->input_name()]) && $_POST[$this->input_name()] == $this->returned_value) {
00046       $this->value = $this->returned_value;
00047     }
00048     else {
00049       $this->value = false;
00050     }
00051   }
00052 
00058   public function set_returned_value($returned_value)
00059   {
00060     $this->returned_value = $returned_value;
00061     return $this;
00062   }
00063 
00064   public function set_value($value, $manually = true)
00065   {
00066     if($value != false) {
00067       $this->returned_value = $value;
00068     }
00069     return parent::set_value($value, $manually);
00070   }
00071 
00072 
00073 }
00074 
00075 ?>

Generated on Sun Aug 4 2013 12:51:43 for Habari by  doxygen 1.7.1