acoustic_overdrive wrote:
> I just thought of a little function that I wanted to get some feedback
> on. It's a way to pre-populate a form when adding new records, using
> the URL only and no controller-specific controller logic.
>
> In AppController::beforeRender :
>
> if(isset($_REQUEST['populate'])) {
>       if(empty($this->data)) {
>               $this->data = array();
>       }
>       $this->data = array_merge_recursive($this->data,$_REQUEST
> ['populate']);
> }
>
> then make a link pointing to an ADD form:
>
> /admin/project_images/add?populate[ProjectImage][project_id]=3&populate
> [ProjectImage][name]=blah
>
> What do you think? Not very cakey with that querystring but is there a
> better way to do this?
>
>   
<?= $form->input('ProjectImage.project_id', array('value' => '3'));?>
<?= $form->input('ProjectImage.name', array('value' => 'blah'));?>



--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to