So I'm moifying the admin generator to handle embedded forms. I have
the save and insert functionality working fine and quite easily as
well. However, when I try to implement the delete functionality I can
have it delete the related record, but the I receive error about
property that was supposed to be in that embedded record. I wanted to
know if there is a way, and if so what is the proper way to remove an
embedded form and/or fields from a form once it has already been
submitted. A few attempts are below and all yield similar errors
about my related objects id being invalid.
Thanks for any help with this.
{{{
#/actions/actions.class.php
public function executeUpdate(sfWebRequest $request)
{
$this->sw2_bind_domain = $this->getRoute()->getObject();
$this->form = $this->configuration->getForm($this-
>sw2_bind_domain);
//get the submit value from the request, and split it into an
array of command, id
$submit = ($request->hasParameter('submit') ? $request-
>getParameter('submit') : '_');
$submit = explode('_',$submit);
switch ($submit[0])
{
case 'insert':
$this->sw2_bind_domain['Records'][] = new sw2BindRecord();
break;
case 'delete':
$this->forward404Unless($record = Doctrine::getTable
('sw2BindRecord')->find($submit[1]));
$record->delete();
# Up to here works
// None of the following work
$this->form->offsetUnset('sw2_bind_domain[records][record_'.$submit
[1].'][id]');
unset($this->form->getValidator('records'));
unset($this->form['records']['record_'.$submit[1]]);
unset($request->parameters['records']['record_'.$submit[1]]);
$this->form->removeRecord($submit[1]);
break;
}
$this->processForm($request, $this->form);
$this->setTemplate('edit');
}
}}}
{{{
#/lib/model/form/DomainForm.class.php
// I thought accessing it from within the class might work better
public function removeRecord($id)
{
$this->offsetUnset($this['records']['record_'.$id]);
unset($this['record_'.$id]);
}
}}}
--
Stephen Ostrow <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---