Try adding var $helpers = array('Form'); in your controller
On May 19, 2:33 pm, vishal <[EMAIL PROTECTED]> wrote: > Hi All, > > I am new user on this community.I am not an expert in > cake.so please help me in this issue. > > undefined variable $form > > This is my add.ctp file : > > <h1>Add User</h1> > > <?php > echo $form->create('User');?> > echo $form->input('name'); > echo $form->input('address', array('rows' => '3')); > echo $form->input('phone'); > echo $form->input('mobile'); > echo $form->input('email'); > echo $form->input('city'); > echo $form->input('state'); > echo $form->input('image',array('type' => 'file')); > echo $form->end('Save User'); > ?> > > This is the controller file: > > <?php > class UsersController extends AppController { > > var $name = 'Users'; > var $layout='user'; > //var $layout='edit'; > > /* var $validate = array( > > 'name' => VALID_NOT_EMPTY, > 'address' => VALID_NOT_EMPTY, > 'phone' => VALID_NUMBER, > 'mobile' => VALID_NUMBER, > 'email' => VALID_EMAIL, > 'city' => VALID_NOT_EMPTY, > 'state' => VALID_NOT_EMPTY, > 'image' => VALID_NOT_EMPTY, > 'born' => VALID_NUMBER > ); > > */ > var $validate = array( > 'name' => array( > 'rule' => array('minLength', 1), > 'message' => 'please enter the name' > ), > 'address' => array( > 'rule' => array('minLength', 1) > ) > ); > > var $paginate = array( > 'limit' => 4, > 'order' => array( > 'User.name' => 'asc' > ) > ); > > function index() { > // $this->set('users', $this->User->find('all')); > // $data = $this->paginate('User'); > //$this->set(compact('data')); > > $this->set('users', $this->User->findAll()); > > } > > function view($id) { > $this->User->id = $id; > $this->set('user', $this->User->read()); > > } > > function delete($id) { > $this->User->del($id); > $this->flash('The user with id: '.$id.' has been deleted.', 'http:// > 192.168.0.60/vishal/cake_1.2.0.6311-beta/app/users/index'); > > } > > function add() { > if (!empty($this->data)) { > if ($this->User->save($this->data)) { > $this->flash('Your detail has been saved.','/users/ > index'); > } > > } > } > > function edit($id = null) { > $this->User->id = $id; > if (empty($this->data)) { > $this->data = $this->User->read(); > } else { > if ($this->User->save($this->data['User'])) { > $this->flash('Your detail has been updated.','http:// > 192.168.0.60/vishal/cake_1.2.0.6311-beta/app/users/index'); > } > } > > } > } > > ?> > > when i execute /users/add This gives me an error : > > undefined variable $from. I don't know why this error occurs.same case > occurs in editing . > > Is there any other way to create a form > > Thanks, in advance !!!! > > Vishal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---