On Sun, Jan 30, 2011 at 11:55 AM, tom <tb...@live.co.uk> wrote: > Create a database table with the correct fields, perhaps called > 'Settings'. > > You can then create (or bake) a model and controller to go with the > table. > > The controller only needs an edit action. The action should get the id > for the model from the applications configuration, rather than a > variable passed to it like normal. Here's what I mean: > > class SettingsController extends AppController { > > var $name = 'Settings'; > > function admin_edit() { > if (empty($this->data)) { > $this->data = $this->Setting->read(null, > Configure::read('settingsId')); > } else { > if ($this->Setting->save($this->data)) { > Cache::delete('settings'); > $this->Session->setFlash('Settings saved.'); > $this->redirect('/'); > } else { > $this->Session->setFlash('Settings could not > be saved. Please try > again.'); > } > } > } > } > > Notice that Configure::read('settingsId') is used to provide the id of > the row in the database. > > So in /config/core.php you could put: > > Configure::write('settingsId', 1);
The ID never changes? Are you using just a single row in the database? Why not pass the $id as a param? -- 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