To access the data in your view (assuming you are using the default
find for the action), you use the variable that corresponds to the
model name.
So for instance in your example, you'd write:
<?php echo $html->link(__('Cancel', true), array('action'=>'index',
$staff_hour['StaffHour']['staff_id']));?>
This does depend entirely on how you implement the model action. If
for example in your controller you did a find, and then set like:
$this->set('staffHours', $staffHours);
You would instead use the following:
<?php echo $html->link(__('Cancel', true), array('action'=>'index',
$staffHours['StaffHour']['staff_id']));?>
This should now be as clear as mud ;)
On Dec 9, 11:02 am, WebbedIT <[EMAIL PROTECTED]> wrote:
> Hopefully a simple one to answer.
>
> In my controllers, if I add data into the $this->data array form
> fields are automatically populated
>
> Controller:
> $this->data['StaffHour']['staff_id'] = 123;
>
> View:
> echo $form->input('StaffHour.staff_id', array('type' => 'hidden'));
>
> HTML Output:
> <input name="data[StaffHour][staff_id]" value="123"
> id="StaffHourStaffId" type="hidden">
>
> However when I then try to access the $data array elsewhere in the
> view it is undefined?!?
>
> Elsewhere in view:
> <?php echo $html->link(__('Cancel', true), array('action'=>'index',
> $data['StaffHour']['staff_id']));?>
>
> Nor can I user debug($data) ... this is highly confusing, how does the
> form helper access the $data array?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---