1 to 3 of 3
I assume that when you are creating the input forms, you have the organization ID availible. If so, then simply put it in a hidden field inside the form (the _form.tpl inside your views/producer/ folder), and fill it's 'value' with the 'organization_id'. Something like this:
<?php echo $form_helper->hidden_field('producer','organization_id',array('value' => $organization->id )); ?>
Everything in the form is transferred to the database when you do a SAVE (as long as the field name is correct).
Another way: you could make a 'add producer to organisation' action in the organisation controller.
That way you could pass the ID of the organisation with a special route.
$Map->connect('/organisation/:id/producer/', array(
'controller' => 'organisation',
'action' => 'add_producer'
));
and in the organisation controller:
function add_producer(){
if(!empty($this->params['producer'])){
$this->Producer->setAttributes($this->params['producer']);
$this->Producer->organization_id = $this->params['id'];
if ($this->Request->isPost() && $this->Producer->save()){
$this->flash['notice'] = $this->t('Producer was successfully created.');
$this->redirectTo(array('action' => 'show', 'id' => $this->producer->getId()));
}
}
}
.. or something like that
1 to 3 of 3