Re: Accessing Array Data the view (not index) File :: Where am I wrong?

2009-05-22 Thread John Andersen

If I understand you correctly, then you are trying to add a new
comment to the task, not to another comment, correct?

Assuming I am correct :) ... use:

$task['Task']['id']

so that you add method will know which task to add the comment to!

This could also be done, without referring to the task in the URL, if
you are only viewing and commenting one task at a time, by tracking
which task is being viewed - in the view method, use:

$this->Session->write('Task.View.Id', $task['Task']['id']);

and then in the comment add method, use:

$currentTaskId = $this->Session->read('Task.View.Id');

to get the task id to which to add the comment!

Hope this helps you on the way,
   John

On May 22, 8:34 am, programguru  wrote:
[snip]
>
> But now I'm facing a new issue. I need to be able to post a comment from the
> Task view page, and I'm trying to work out the url.
>
> Any advice on this one? This is what I have, and it's not working. It's
> defaulting to the Add Task action:
>
> echo $html->link(__('New Comment', true), array('action'=>'add',
> $task['Comment']['comment'])); ?>
[snip]
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Accessing Array Data the view (not index) File :: Where am I wrong?

2009-05-21 Thread programguru


Hi John,

Thanks for your advice. I was able to get it to work with:

foreach ($task['Comment'] as $Comment => $comment ):

But now I'm facing a new issue. I need to be able to post a comment from the
Task view page, and I'm trying to work out the url.

Any advice on this one? This is what I have, and it's not working. It's
defaulting to the Add Task action:

echo $html->link(__('New Comment', true), array('action'=>'add',
$task['Comment']['comment'])); ?>
-- 
View this message in context: 
http://www.nabble.com/Accessing-Array-Data-the-view-%28not-index%29-File-%3A%3A-Where-am-I-wrong--tp23664192p23664688.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Accessing Array Data the view (not index) File :: Where am I wrong?

2009-05-21 Thread John Andersen

The Comment array is deeper than you think!

Use:
 $comment ) {
   echo $comment['comment'];
}
?>

Enjoy,
   John


On May 22, 7:24 am, programguru  wrote:
> I am trying to echo out my Comment data to my Task view file, and it will not
> work!
>
> Does anyone know if it is possible to print the [comment] field value? I am
> able to print all Task related items with for example  $task['Color']['name']; ?>. this works OK.
>
> But when I try to print:  nothing
> will echo? even though I can see my array with debug and all of the data
> is there?
>
> What am I doing wrong?
>
> [Color] => Array
>         (
>             [id] => 7
>             [name] => productionTaskStatus
>         )
>
>     [Comment] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 1
>                     [comment] => this is a test comment
>                     [task_id] => 40
>                 )
>
>             [1] => Array
>                 (
>                     [id] => 2
>                     [comment] => sdfsdfsdfds
>                     [task_id] => 40
>                 )
>
>             [2] => Array
>                 (
>                     [id] => 3
>                     [comment] => this is a test comment
>                     [task_id] => 40
>                 )
>
>         )
>
> )
>
> --
> View this message in 
> context:http://www.nabble.com/Accessing-Array-Data-the-view-%28not-index%29-F...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Accessing Array Data the view (not index) File :: Where am I wrong?

2009-05-21 Thread programguru


I am trying to echo out my Comment data to my Task view file, and it will not
work!

Does anyone know if it is possible to print the [comment] field value? I am
able to print all Task related items with for example . this works OK.

But when I try to print:  nothing
will echo? even though I can see my array with debug and all of the data
is there?

What am I doing wrong?

[Color] => Array
(
[id] => 7
[name] => productionTaskStatus
)


[Comment] => Array
(
[0] => Array
(
[id] => 1
[comment] => this is a test comment
[task_id] => 40
)

[1] => Array
(
[id] => 2
[comment] => sdfsdfsdfds
[task_id] => 40
)

[2] => Array
(
[id] => 3
[comment] => this is a test comment
[task_id] => 40
)

)

)

-- 
View this message in context: 
http://www.nabble.com/Accessing-Array-Data-the-view-%28not-index%29-File-%3A%3A-Where-am-I-wrong--tp23664192p23664192.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---