Exemple #1
0
 public function __construct(array $dataray = array())
 {
     if (isset($dataray['form']) && is_object($dataray['form']) && $dataray['form'] instanceof \System\Form) {
         $this->form = $dataray['form'];
         unset($dataray['form']);
     } else {
         throw new \System\Error\Argument("You must pass instance of 'System\\Form' into element attributes.");
     }
     parent::__construct($dataray);
 }
Exemple #2
0
 /**
  * Public constructor compatible with attr model
  * @return $this
  */
 public function __construct(array $dataray = array())
 {
     $this::$instance_count++;
     return parent::__construct($dataray);
 }
Exemple #3
0
 public function to_object()
 {
     $containers = array();
     $attrs = parent::get_data();
     $attrs['name'] = $this->name;
     $attrs['use_comm'] = $this->use_comm;
     $attrs['use_errors'] = $this->use_errors;
     $attrs['use_queue'] = $this->use_queue;
     $attrs['prefix'] = $this->get_prefix();
     unset($attrs['response']);
     unset($attrs['request']);
     unset($attrs['renderer']);
     foreach ($this->objects as $obj) {
         $containers[] = $obj->to_object();
     }
     $containers[] = array("element" => "input", "type" => 'hidden', "name" => $this->get_prefix() . 'data_hidden', "value" => json_encode($this->data_hidden));
     $attrs['elements'] = $containers;
     $attrs['data'] = $this->get_data(true);
     $attrs['initial_check'] = $this->submited;
     foreach ($attrs['data'] as $key => $value) {
         if (is_null($value)) {
             unset($attrs['data'][$key]);
         } else {
             if ($value instanceof \DateTime) {
                 $attrs['data'][$key] = $value->format('c');
             } else {
                 if (method_exists($value, 'to_object')) {
                     $attrs['data'][$key] = $value->to_object();
                 }
             }
         }
         $input = $this->get_input(preg_replace('/^' . $this->get_prefix() . '/', '', $key));
         if ($input && $input->type == 'password') {
             unset($attrs['data'][$key]);
         }
     }
     return $attrs;
 }