| 133 | | $hidden = array(); |
| 134 | | if ( ! empty($this->hidden)) |
| 135 | | { |
| 136 | | foreach($this->hidden as $input) |
| 137 | | { |
| 138 | | $hidden[$input->name] = $input->value; |
| 139 | | } |
| 140 | | } |
| 141 | | |
| 142 | | $form_type = 'open'; |
| 143 | | // See if we need a multipart form |
| 144 | | foreach ($this->inputs as $input) |
| 145 | | { |
| 146 | | if ($input instanceof Form_Upload) |
| 147 | | { |
| 148 | | $form_type = 'open_multipart'; |
| 149 | | break; |
| 150 | | } |
| 151 | | } |
| 152 | | |
| 153 | | // Set the form open and close |
| 154 | | $form->open = form::$form_type(arr::remove('action', $this->attr), $this->attr, $hidden); |
| 155 | | $form->close = form::close(); |
| 156 | | |
| 157 | | // Set the inputs |
| 158 | | $form->inputs = $this->inputs; |
| 159 | | |
| 160 | | return $form->render(); |
| | 146 | if ($custom) |
| | 147 | { |
| | 148 | // Using a custom view |
| | 149 | |
| | 150 | $data = array(); |
| | 151 | foreach ($this->inputs as $input) |
| | 152 | { |
| | 153 | $data[$input->name] = $input; |
| | 154 | |
| | 155 | // Compile the error messages for this input |
| | 156 | $messages = ''; |
| | 157 | $errors = $input->error_messages(); |
| | 158 | if (is_array($errors) AND ! empty($errors)) |
| | 159 | { |
| | 160 | foreach($errors as $error) |
| | 161 | { |
| | 162 | // Replace the message with the error in the html error string |
| | 163 | $messages .= str_replace('{message}', $error, $this->error_format).$this->newline_char; |
| | 164 | } |
| | 165 | } |
| | 166 | |
| | 167 | $data[$input->name.'_errors'] = $messages; |
| | 168 | } |
| | 169 | |
| | 170 | $form->set($data); |
| | 171 | } |
| | 172 | else |
| | 173 | { |
| | 174 | // Using a template view |
| | 175 | |
| | 176 | $hidden = array(); |
| | 177 | if ( ! empty($this->hidden)) |
| | 178 | { |
| | 179 | foreach($this->hidden as $input) |
| | 180 | { |
| | 181 | $hidden[$input->name] = $input->value; |
| | 182 | } |
| | 183 | } |
| | 184 | |
| | 185 | $form_type = 'open'; |
| | 186 | // See if we need a multipart form |
| | 187 | foreach ($this->inputs as $input) |
| | 188 | { |
| | 189 | if ($input instanceof Form_Upload) |
| | 190 | { |
| | 191 | $form_type = 'open_multipart'; |
| | 192 | } |
| | 193 | } |
| | 194 | |
| | 195 | // Set the form open and close |
| | 196 | $form->open = form::$form_type(arr::remove('action', $this->attr), $this->attr, $hidden); |
| | 197 | $form->close = form::close(); |
| | 198 | |
| | 199 | // Set the inputs |
| | 200 | $form->inputs = $this->inputs; |
| | 201 | } |
| | 202 | |
| | 203 | return $form; |