Thursday, March 25, 2010

Re: access global inputfields in multiple controller

I've figured out a solution, but I'd like to get some feedback if it's
complete crazy to do something like this:

in views/layouts/default.ctp I added
<div id="navigation">
<?php echo $this->renderElement('menus/navigation'); ?>
</div>

views/elements/menues/navigation.ctp :
<div>
<?php
echo $html->link(".events","/events");
echo $html->link(".players","/players");
echo $html->link(".teams","/teams");
?>
</div>
<div>
<?php
$target = array();
$target['controller'] = $this->params['controller'];
$target['action'] = $this->params['action'];

foreach($this->params['pass'] as $parameter) {
$target[] = $parameter;
}

echo $form->create(null, array('url' => $target));
echo $form->input('some_text');
echo $form->end();
?>
</div>

so basically I create a form, that posts it value to the current
controller with all the passed parameters (reload with additional form
value).
this works, but I'm not sure if this approach is 'OK'. I also wonder
if there is a more elegant way to call the create function without
building the $target array. like:

$form->create(null, array('url' => array( 'controller' => $this-
>params['controller'], 'action' => $this->params['controller'], $this-
>params['pass'])));

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: