For the form helper - if you have $form->create('YourModel'); then the
form helper will automatically use the "YourModel" model for the
form. However, you can also create each form item with $form-
>input('OtherModel.somefield') to use any other model.
The data that prepopulates these fields is taken from $this->data in
your controller. So if you populate $this->data['YourModel'] and
$this->data['OtherModel'] in the controller (through reading the
appropriate rows, or a requestAction) then your form can prepopulate.
And as Chris mentioned, if you are going to use a form on multiple
screens it makes sense to use an element.
On Dec 17, 4:18 am, "Jon Miller" <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to change the default model used by a page? I
> need to try to 'fool' Cake into believing it's running from a
> different URL in part of the page.
>
> My example is for classified listings. On my listings index page,
> underneath the main content from the listings controller, I have a
> form allowing a user to edit their personal profile at any time - and
> should show a pre-filled form, as you'd get by going to
> /profiles/edit/4.
>
> I tried using RequestAction in the following but it didn't work as all
> that does is return the results of that page, it doesn't change the
> "this->..." info being used:
>
> <?
> echo $this->model;
> // returns "Listing"
>
> $this->data = $this->requestAction('/profiles/edit/4');
>
> echo $this->model;
>
> // still echoes 'Listing', not 'Profile' as hoped.
>
> ?>
>
> Can anyone tell me how to achieve this change, as RequestAction
> clearly doesn't work. I need to change it so that the form helper
> (using the value function in helper.php) will populate, as it takes
> its criteria from $this->data[$this->model][$this->field] and if it's
> using the wrong model to start with, it's not going to populate the
> form correctly.
>
> Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---