00001 <?php
00002
00015 class TKCheckBox extends TKFormInput {
00022 public function __construct($name, $value = "", $checked = false) {
00023 parent::__construct('checkbox', $name, $value);
00024 $this->addProperty('checked', self::PROP_BOOLEAN);
00025 $this->set('checked', $checked);
00026
00027 $this->addEvent('oncheck', self::EVENT_INDIRECT);
00028 $this->addEvent('onuncheck', self::EVENT_INDIRECT);
00029
00030 $this->setAction('onchange', "if(this.checked==true){");
00031 $this->setAction('onchange', new TKEmitAction($this, 'oncheck'));
00032 $this->setAction('onchange', "}else{");
00033 $this->setAction('onchange', new TKEmitAction($this, 'onuncheck'));
00034 $this->setAction('onchange', "}");
00035 }
00036
00038 public function renderComponent($class, $style, $events, $id) {
00039 if($this->get('checked') == true)
00040 $events .= " checked=\"checked\"";
00041 return parent::renderComponent($class, $style, $events, $id);
00042 }
00043 }