コード例 #1
0
ファイル: fieldset.php プロジェクト: takawasitobi/pembit
 /**
  * Add a new Fieldset_Field before an existing field in a Fieldset
  *
  * @param   string  $name
  * @param   string  $label
  * @param   array   $attributes
  * @param   array   $rules
  * @param   string  $fieldname   fieldname before which the new field is inserted in the fieldset
  * @return  Fieldset_Field
  */
 public function add_before($name, $label = '', array $attributes = array(), array $rules = array(), $fieldname = null)
 {
     $field = $this->add($name, $label, $attributes, $rules);
     // Remove from tail and reinsert at correct location
     unset($this->fields[$field->name]);
     if (!\Arr::insert_before_key($this->fields, array($field->name => $field), $fieldname, true)) {
         throw new \RuntimeException('Field "' . $fieldname . '" does not exist in this Fieldset. Field "' . $name . '" can not be added.');
     }
     return $field;
 }
コード例 #2
0
 /**
  * Insert before a specific key.
  * 
  * @access public
  * @return void
  */
 public function insert_before($key, $title, $callback, $ukey = null)
 {
     $this->prepare_insert($callback, $ukey);
     \Arr::insert_before_key($this->properties, $title, $key);
     $this->properties = \Arr::replace_key($this->properties, array(0 => $ukey));
     return $this;
 }