I have two models namely 'Client' and 'Pet' which have admin generated modules for each. There is a one-to-many relationship involved so I want to be able to create a new Pet using a cid (client id) specified in the URL (i.e. /pet/new/cid/6)
I already disabled the cid field in the Client form so that the parameter from the URL will be passed as the default value.
I tried overriding the actions.class.php of the admin generated module with this code:
public function executeCreate(sfWebRequest $request)
{
$this->form = $this->configuration->getForm();
$params = $request->getParameter($this->form->getName());
$params["cid"] = $request->getParameter('cid');
$request->setParameter($this->form->getName(), $params);
parent::executeCreate($request);
}
It works if i replaced
$request->getParameter('cid');
with a hard-coded int value so I think the problem is that I'm not able to get the parameter from the URL.
I think I might be missing on some routing configurations but I'm fairly new to this framework so I'm not really sure what to do.