Пример #1
0
 public function mapFormFromRequest($raw_values = array())
 {
     if (!$this->form->initialised) {
         $this->form->initialise();
     }
     foreach ($this->request->getRawRequest() as $key => $value) {
         if ($key == 'id') {
             $this->form->record_id = substr($value, 0, 3) == 'new' ? $value : intval($value);
         }
         if ($this->form->fieldExists($key, true)) {
             $field = $this->form->getField($key, true);
             if (array_search($key, $raw_values) !== false) {
                 $field->setValueRaw($this->request->getRequestParam($key, null, null));
             } else {
                 $field->setValue($this->request->getRequestParam($key));
             }
             if (array_key_exists('confirm_' . $key, $_REQUEST)) {
                 $field->setConfirmValue($this->request->getRequestParam('confirm_' . $key));
             }
         }
     }
     //If any values were not sent back, mark them as not published
     foreach ($this->form->field_sets as &$field_set) {
         foreach ($field_set->fields as &$field) {
             switch ($field->type) {
                 case 'button':
                 case 'submit':
                 case 'reset':
                 case 'container':
                     continue;
                 default:
                     if (!$field instanceof FieldLinkButton) {
                         if (!array_key_exists($field->name, $_REQUEST) && !array_key_exists($field->name, $_FILES)) {
                             $field->published = false;
                         }
                     }
                     break;
             }
         }
     }
     return $this->form;
 }