the usual recommendation: you should use the bake script to bake your code: "cake bake ..." from the console. this way you save time and learn a lot more than doing it the hacky way yourself (besides the fact that it should prevent you from writing unsafe/ faulty code)
On 12 Dez., 15:42, Tilen Majerle <tilen.maje...@gmail.com> wrote: > you need to populate data array in your controller > Cake 1.3: $this->data = array('ModelName' => array('key1' => 'value1')); > Cake 2.0: $this->request->data = array('ModelName' => array('key1' => > 'value1")); > > and then in form helper in 'create' method first parameter is default > ModelName > and when you use $this->Form->input('key1') it will search in data array in > "ModelName.key1" and value inside will be "value1" > > Understand ? :) > > -- > Lep pozdrav, Tilen Majerlehttp://majerle.eu > > 2011/12/12 Anton Shevchenko <2tamt...@gmail.com> > > > > > > > > > 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 openhttp://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 sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php