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

system/controls/formcontrolcheckboxes.php

00001 <?php
00002 
00003 namespace Habari;
00004 
00008 class FormControlCheckboxes extends FormControlSelect
00009 {
00010   public function get(Theme $theme)
00011   {
00012     $checkboxes = $this->options;
00013     $control = $this;
00014 
00015     if(!is_array($control->value)) {
00016       $control->value = array();
00017     }
00018     array_walk(
00019       $checkboxes,
00020       function(&$item, $key) use($control) {
00021         $item = array(
00022           'label' => Utils::htmlspecialchars($item),
00023           'id' => Utils::slugify( $control->get_id() . '-' . $key ),
00024           'checked' => in_array($key, $control->value) ? 'checked="checked"' : '',
00025         );
00026       }
00027     );
00028     $this->vars['checkboxes'] = $checkboxes;
00029     $this->settings['ignore_name'] = true;
00030     return parent::get($theme);
00031   }
00032 
00033 
00037   public function process()
00038   {
00039     if(isset($_POST[$this->input_name()])) {
00040       $this->value = $_POST[$this->input_name()];
00041     }
00042     else {
00043       $this->value = false;
00044     }
00045   }
00046 
00047 }
00048 
00049 ?>

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