コード例 #1
0
 /**
  * Returns all the section fieldset fields rules.
  *
  * @param  \Cartalyst\Settings\Section  $section
  * @return array
  */
 protected function getRules(Section $section)
 {
     $rules = [];
     foreach ($section->all() as $fieldset) {
         foreach ($fieldset->all() as $field) {
             if ($_rules = $field->rules) {
                 $rules[$field->id] = $_rules;
             }
         }
     }
     return $rules;
 }
コード例 #2
0
 /**
  * Prepares the given section fieldset fields.
  *
  * @param  \Cartalyst\Settings\Section  $section
  * @return array
  */
 public function prepare(Section $section)
 {
     $data = $section->all();
     foreach ($data as $fieldset) {
         foreach ($fieldset->all() as $field) {
             if (!($config = $field->config)) {
                 throw new InvalidArgumentException("Field [{$field->id}] from section [{$section->id}] is missing the \"config\" attribute!");
             }
             $field->value = $this->request->old($field->id, $this->config->get($config));
         }
     }
     return $data;
 }