Example #1
0
 /**
  * add_group method. Add a new Form_Group object to form
  *
  * @return object
  */
 public function add_group($name, $values, $info = NULL)
 {
     $add_name = strtolower(preg_replace('/\\[\\]/', '', $name));
     $defaults = $this->_make_defaults($add_name, $add_name);
     $defaults_globals = array_merge($this->_globals, $defaults);
     $this->{$add_name} = Formo_Group::factory($name, $values, $info);
     foreach ($defaults_globals as $setting => $value) {
         $this->{$add_name}->{$setting} = $value;
     }
     self::$last_accessed = $add_name;
     return $this;
 }
Example #2
0
 /**
  * add method. Add a new Form_Element object to form
  *
  * @return object
  */
 public function add($type, $name = '', $info = array())
 {
     $original_type = $type;
     if (!$info and !$name) {
         $name = $type;
         $type = 'text';
     } elseif (!$info and (is_array($name) or preg_match('/=/', $name))) {
         $info = $name;
         $name = $type;
         $type = 'text';
     }
     $obj_name = strtolower(str_replace(' ', '_', $name));
     if (isset($this->{$obj_name})) {
         return $this;
     }
     // check if this needs to change types first
     if ($original_type != $type and isset($this->_defaults[strtolower($name)]['type'])) {
         $type = $this->_defaults[strtolower($name)]['type'];
     }
     $info = $this->process_info($info, $type, $name);
     $info['type'] = $type;
     self::include_file('driver', $info['type']);
     $file = 'Formo_' . $info['type'] . '_Driver';
     $el = new $file($name, $info);
     $this->{$obj_name} = $el;
     self::$last_accessed = $obj_name;
     $this->_attach_auto_rule($obj_name);
     return $this;
 }