I was hoping for some info on how to take 4 functions and make the into
1.They all do the same thing except its a different model that they use.
They simply update a users options thru a select check box form, that's the
only thing being edited. Basically I took the edit view and broke it up into
4 different Ajax edits and each has its own function but since they are all
the same except for the model call I was hoping someone could give me some
advice on creating 1 standard function.
 
They all get called from the same page  users/profile, the link in the view
is users/profile/[user slug]/update_eductions or users/profile/[user
slug]/update_skills. I am still very new with cake but was thinking if I
modified the link url used an additional variable based on the link action
to get users/profile/[user slug]/educations/update  I could then use 1
function called update and set the "educations" in the url to define what
model to update and pass that into the function. the update function would
be something like function update ($slug, $modelName) then in the old
function replace the model name with $modelName ?
 
function update_eductions($slug = null)
      {
          $this->User->recursive = 1;
          if ($this->RequestHandler->isAjax()) {
     $user = $this->User->findBySlug($slug);
          $id = $user['User']['id'];
              $this->set('user', $this->User->read(null, $id));
              if (!empty($this->data)) {
                  if ($this->User->save($this->data)) {
                      $this->view_educations($slug);
                  }
              }
              $educations= $this->User->Educations->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
              $this->set(compact('educations'));
          }
          if (empty($this->data)) {
              $this->data = $this->User->read(null, $id);
          }
      }
 
or to update skills
 
function update_skills($slug = null)
      {
          $this->User->recursive = 1;
          if ($this->RequestHandler->isAjax()) {
     $user = $this->User->findBySlug($slug);
          $id = $user['User']['id'];
              $this->set('user', $this->User->read(null, $id));
              if (!empty($this->data)) {
                  if ($this->User->save($this->data)) {
                      $this->view_skills($slug);
                  }
              }
              $skills= $this->User->Skills->find('list', array('fields' =>
'name', 'order' => 'name ASC'));
              $this->set(compact('skills'));
          }
          if (empty($this->data)) {
              $this->data = $this->User->read(null, $id);
          }
      }
 
Ideas? Suggestions?
 
Thanks,
 
Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to