On Wed, Mar 18, 2009 at 10:05 AM, Matt <[email protected]> wrote:
>
> Thanks, but I need a little more help on this one....
>
> So, when I click on the add resource button, I include the id of the
> supplier as an argument, and create the hidden field in the form, but
> the field is not getting populated!
>
> My url is: http://localhost/dmsmca/resources/add/1
>
> This is how I assign the variable in the controller:
> function add($area_id)
>
> And this is how it looks in my view:
> echo $form->input('area_id', array('type'=>'hidden'));
>
> However, if I look at the source, it's null:
> <input type="hidden" name="data[Resource][area_id]" value=""
> id="ResourceAreaId" />
Is that input in the add view? Or is it in the form with the 'add' button?
If the latter, and you want $area_id to be in the route (and, thus,
passed as a param to the method) you'll need to give it to FormHelper
so it can add it to the action attribute of the form:
$form->create(array('controller' => 'resources', 'action' => 'add', $area_id));
Or, depending on how you have your route set up:
$form->create(array('controller' => 'resources', 'action' => 'add',
'area_id' => $area_id));
If the input you mentioned is in the add view, you'll need to set the
var in the controller:
$this->set('area_id', $area_id);
view:
$form->input('area_id', array('type' => 'hidden', 'value' => $area_id))
This is a little bit confusing because you're talking about Contacts &
Resellers but the code you're showing seems to be about Areas &
Resources.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---