Hello Thomas...
Im sort of very new with Cakephp and I'm using/learning v2.3..
I'm not good enough (yet) to know exactly what is wrong, but it seems you
didn't follow naming "conventions"... And as I understood, for the magic
to happen, it needs to be consistent..
CategoriesController.php
> <?php
> class CategoriesController extends AppController {
> public $helpers = array('Html', 'Form');
> public $components = array('Session');
>
> public function index() {
> $this->set('Categories', $this->Category->find('all')); *//
> Here, it should be 'categories' (no capital C)*
> }
> public function view($id = null) {
> if (!$id) {
> throw new NotFoundException(__('Invalid category'));
> }
> $CatRec = $this->Category->findById($id); *// $categorie =
> $this..*
> if (!$CatRec) { *// !$categorie*
> throw new NotFoundException(__('Invalid category'));
> }
> $this->set('Categories', $CatRec); *// $this->set('categorie',
> $categorie);*
> }
> public function add() {
> if ($this->request->is('post')) {
> $this->Category->create();
> if ($this->Category->validates()) { *// I think the
> validates will be done by itself on the save, you dont need to add it here.
> (Im not sure though)*
>
> if ($this->Category->save($this->request->data)) {
> $this->Session->setFlash('Your Category has been saved.');
> // $this->redirect(array('action' => 'index'));
> } else {
> $this->Session->setFlash('Unable to add your Category.');
> }
> }else {
> $this->Session->setFlash('Unable to validate.');
> }
>
> }
> }
> }
>
> Category.php
>
> <?php
> class Category extends AppModel {
> public $validate = array(
> 'Name' => array('rule' => 'notEmpty'), *// 'name' => 'notEmpty',*
> 'Description' => array('rule' => 'notEmpty'), *// 'description'
> => 'notEmpty',*
> 'Type' => array('rule' => 'notEmpty') *// 'type' => 'notEmpty'
> no Capitals, no new array*
> );
> }
>
> any help appreciated
>
> Thomas
>
>
>
and seeing your add.ctp would help also if all those changes dont work.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.