In one of my forms I have a text input for a posts tags. At the moment, Cake is returning the tag id into this field rather than the name of the tag. I want to change it to show the name of the tag.
The posts controller is getting a result like this:
array(
'Post' => array(
'id' => '7',
'title' => 'Testing again',
'body' => 'wooooooo',
'created' => '2013-01-09 19:20:53',
'slug' => 'testing-again'
),
'Tag' => array(
(int) 0 => array(
'id' => '4',
'name' => 'tag1'
),
(int) 1 => array(
'id' => '3',
'name' => 'tag2'
),
(int) 2 => array(
'id' => '5',
'name' => 'tag3'
)
)
)
and the form is laid out like this:
<?php echo $this->Form->create('Post'); ?>
<?php echo $this->Form->input('Post.title'); ?>
<?php echo $this->Form->input('Post.body'); ?>
<?php echo $this->Form->input('Tag.Tag', array('type' => 'text', 'label' => 'Tags (seperated by space)')); ?>
<?php echo $this->Form->input('Post.slug'); ?>
<?php echo $this->Form->end('Save Changes'); ?>
Is there a way I can tell CakePHP to output the name
field of the tags instead of id
? Thanks.