http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html
look here, cakephp conventions -- Lep pozdrav, Tilen Majerle http://majerle.eu 2012/2/23 [email protected] <[email protected]> > Hi Tilen, I not understand your point here. As you said I have country_id > as PK and my table is Countries not Country so my model code is this one > (Countries.php): > > class Countries extends AppModel { > public $name = 'Countries'; > } > > then if I use $this->Country->id = $id doesn't work and if I > use $this->Countries->country_id = $id doesn't work too. Which should be > the solution? Change my table structure or what? > > Ing. Reynier Pérez Mira > http://reynierpm.site90.com/ > > > > On Thu, Feb 23, 2012 at 5:02 AM, Tilen Majerle <[email protected]>wrote: > >> you have "country_id" as your primary key in table ? >> >> and "Countries" for modelname ? >> it should be "Country" right ? :) >> >> $this->Countries->country_id = $id; //this is wrong >> here should be ALWAYS "id", so $this->Countries->id = $id; >> >> but u should use camelized and singularized name, so $this->Country->id = >> $id and it will work >> >> >> >> VIEW: >> Form::create(); here you should have the same model name as you pass >> data, "Country" and not CountryFrm >> -- >> Lep pozdrav, Tilen Majerle >> http://majerle.eu >> >> >> >> 2012/2/23 [email protected] <[email protected]> >> >>> Hi every: >>> Take a look at this function: >>> >>> public function edit($id = null) { >>> $this->Countries->country_id = $id; >>> if ($this->request->is('get')) { >>> $this->request->data = $this->Countries->read(); >>> } else { >>> if ($this->Countries->save($this->request->data)) { >>> $this->Session->setFlash(__('The country has been updated.')); >>> $this->redirect(array('action' => 'index')); >>> } else { >>> $this->Session->setFlash(__('Unable to update the country.')); >>> } >>> } >>> } >>> >>> Aparently all seems to be fine but surprise when I call edit method and >>> pass a ID as parameter the data isn't showed in the template, why? Any >>> help? This is the edit.ctp content: >>> >>> <h1>Edit Country</h1> >>> <?php >>> echo $this->Form->create('CountryFrm', array('action' => 'edit')); >>> echo $this->Form->input('country_name'); >>> echo $this->Form->input('iso_code_2'); >>> echo $this->Form->input('iso_code_3'); >>> echo $this->Form->input('country_id', array('type' => 'hidden')); >>> echo $this->Form->end('Save!!!'); >>> >>> >>> Ing. Reynier Pérez Mira >>> http://reynierpm.site90.com/ >>> >>> -- >>> 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 >> > > -- > 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
