If uou populate data array in your controller than form helper will look for this data and populate field with the same name as data key
Dne ponedeljek, 12. december 2011 je poĊĦiljatelj Anton Shevchenko < [email protected]> napisal: > Hello, I'm new to CakePhp and don't understand the next thing: > I'm going through the blog example > I have created 2 different Views for my blog posts > One is view.ctp and the other is edit.ctp > they are similair > <h1>Post <?php echo $post['Post']['id']; ?></h1> > <?php > echo $this->Form->create('Post', array('action'=>'edit')); > echo $this->Form->input('title'); > echo $this->Form->input('body', array('rows' => '3')); > echo $this->Form->input('id', array('type' => 'hidden')); > echo $this->Form->end('Save Post'); > ?> > > But what is strange that is when i open like http://mysite/cake/posts/edit/3 > - form is populated, i see html > =================================================================== > <form id="PostEditForm" accept-charset="utf-8" method="post" action="/ > cake/posts/edit/3"> > <div style="display:none;"> > <input type="hidden" value="POST" name="_method"> > </div> > <div class="input text required"> > <label for="PostTitle">Title</label> > <input id="PostTitle" type="text" value="A title once again" > maxlength="100" name="data[Post][title]"> > </div> > =================================================================== > but when i open http://mysite/cake/posts/view/3 - there is no > population, but <h1>Post <?php echo $post['Post']['id']; ?></h1> > displays correct information from DB > and the html is looks like: > =================================================================== > form id="PostEditForm" accept-charset="utf-8" method="post" > action="/cake/posts/edit"> > <div style="display:none;"> > <div class="input text required"> > <label for="PostTitle">Title</label> > <input id="PostTitle" type="text" maxlength="100" name="data[Post] > [title]"> > </div> > > I'm trying to understand how to correctly auto-populate from with > corresponding text. > Thank you. > > -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
