In making my addon, i see that XF uses just 1 template for both add and edit.
I can't get it to work.
When i include ID, i can't 'add' but edit works. (includes a hidden input in form)
When i don't include ID, i can't edit, as it gives me a duplicate entry error, which tells me it's trying to add, not edit.
I'm testing if the there's a slug in the url (works) and if so, pull that record.
if not, create an entity:
This all seems to work until the editProcess function is called:
any ideas?
I can't get it to work.
When i include ID, i can't 'add' but edit works. (includes a hidden input in form)
When i don't include ID, i can't edit, as it gives me a duplicate entry error, which tells me it's trying to add, not edit.
I'm testing if the there's a slug in the url (works) and if so, pull that record.
if not, create an entity:
Code:
$this->assertPostOnly();
if($params['slug'])
{
$e = $this->getERepo()->findE()->where('slug', $params['slug'])->fetchOne();
if($e){
$e = $this->assertEExists('My\Mod:Es', $e->id);
}
else
{
throw $this->exception($this->notFound(\XF::phrase('not_found')));
}
}
else {
$e = $this->em()->create('My\Mod:Es');
}
$this->editProcess($e)->run();
return $this->redirect($this->buildLink('basepath/section', $e) );
}
This all seems to work until the editProcess function is called:
Code:
protected function editProcess(\My\Ns\Entity\MyEntity $data)
{
$form = $this->formAction();
$input = $this->filter([
//'id' => 'uint', //this field, when toggled on or off dictates what works for add or edit
'notes' => 'str',
]);
$form->basicEntitySave($data, $input);
return $form;
}
any ideas?