Hi guys,
I created a custom ProcessModule to manage children of an admin page.
The children are always in hidden state and have a template assigned.
I can render the page edit form by template and use ajax upload for images.
After submitting the form I can see that all images are stored in the assets folder but they aren't saved in the database.
All the other inputfields (text, textarea, checkbox...) were saved correctly.
Could you please help me?
Here is the code is use for the form:
public function ___executeEdit() {
$page = $this->pages->get($this->input->get->id);
if($this->config->ajax && (isset($_SERVER['HTTP_X_FIELDNAME']) || count($_POST))) {
$this->ajaxSave($page);
return '';
}
$this->headline(__('Edit'));
$this->breadcrumb('../', $this->page->title);
$form = $this->modules->get("InputfieldForm");
$form->attr('id', 'PageIDIndicator');
$form->attr('action', './?id='.$page->id);
$form->attr('method', 'post');
$form->attr('enctype', 'multipart/form-data');
$form->attr('autocomplete', 'off');
$form->attr('data-uploading', $this->_('Are you sure? An upload is currently in progress and it may be lost if you proceed.'));
// fields
$inputfields = $page->getInputfields();
$form->append($inputfields);
// save
$field = $this->modules->get("InputfieldButton");
$field->type = 'submit';
$field->name = 'submit_save';
$field->value = $this->_("Save");
$form->add($field);
// delete
$field = $this->modules->get("InputfieldButton");
$field->type = 'submit';
$field->name = 'submit_delete';
$field->value = $this->_("Delete");
$form->add($field);
if($this->input->post->submit_save) {
$form->processInput($this->input->post);
$errors = $form->getErrors();
if(count($errors)) {
// show errors
return $form->render();
}
else {
// save values
foreach($page->fields as $field) {
$fieldName = $field->name;
$page->$fieldName = $this->input->post->$fieldName;
}
$page->save();
$this->session->redirect($this->page->url);
}
}
else if($this->input->post->submit_delete) {
$page->delete();
$this->session->redirect($this->page->url);
return true;
}
else {
return $form->render();
}
}