Reputation:
i am little bit new in cakephp, i am making a form for adding class and its section, for this one i have made a controller which code is such like that--- addclasses_controller.php
layout = 'internal'; $session_id=$this->Session->read('User.id'); $username = $this->User->find('all', array('conditions' => array('User.id' =>$session_id))); $this->set('session_id',$username); } function add() { $this->layout = 'internal'; $session_id=$this->Session->read('User.id'); $username = $this->User->find('all', array('conditions' => array('User.id' =>$session_id))); $this->set('session_id',$username); if (!empty($this->data)) { $this->Addclass->create(); $this->red['Addclass']=array('classname'=>$this->data['Addclass']['classname'],'section'=>$this->data['Addclass']['section']); if(!!$this->Addclass->save($this->red)) { $lastid=$this->Addclass->id; $this->Session->setFlash('Categories is Saved!'); $this->redirect(array('action'=>'add'),null, true); } } } function isAuthorized() { return true; } function addsection() { $noofsection=$this->data['Addclass']['section']; $this->set('noofsection',$noofsection); } } ?>and the add.ctp code is--
Add Class create('Addclass', array('url' => array('controller' => 'addclasses', 'action' => 'add'))); ?> Class Nametext('classname',array('class' => 'users')); ?> The Number of Section which you want to addtext('section',array('class' =>'users')); ?> observeField( 'AddclassSection',array('url' => array( 'action' => 'addsection' ),'frequency' => 0.2,'onChange'=>true,'update'=>'employers'));?> end('Submit');?>and the model which i have used for this one---addclass.php
Section-" value="" class="users" name=""/> ///////////////////////////////////////////////////////////////////////////////////// i am trying to access the ajax generrated text value in my add controller when the form is submiited, it access only those which is static in form , for checking this one i have debug($this->data); i got only two value--- **`please help my problem , i really need this one in my cakephp project.`** ?>Upvotes: 2
Views: 1474
Reputation: 11575
From my experience, the ajax helper in cake does not work well. I have replaced it to work with jQuery. You can read more about it here.
Upvotes: 1
Reputation: 3097
Agree with cdburgess - in my experience, the AJAX helper in CakePHP is intended for a very limited and (in my opinion) not very useful purpose - namely, clicking links and updating divs with the result. I ended up using Prototype/Scriptaculous (which are better integrated with CakePHP than jQuery) to manually do AJAX, using Prototype's AJAX functionality with CakePHP's RequestHandler to determine when to return AJAX.
But if you're not doing much more than updating boxes, Reverse Folds has a good article on using CakePHP's helper.
Upvotes: 0