cakephp - pop up window not working shows error Call to a member function url() on a non-object -


here code given code call pop shows error non object

here controller name -dashboardscontroller , function name add()

the view/dashboards/index.ctp

<div id="tabs">   <ul>     <li><a href="#tabs-1">myprofile</a></li>     <li><a href="#tabs-2">patients</a></li>     <li><a href="#tabs-3">list</a></li>   </ul>   <div id="tabs-1">      </div>   <div id="tabs-2">   <?php echo $this->html->link('add patien', array('onclick'=>"var openwin = window.open('".$this->html->url(array('controller'=>'dashboards','action'=>'add')."', '_blank', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=500,height=500');  return false;"))); ?>    <p><?php  //echo $this->html->link('add patient', array('action' => 'add')); ?></p>      <table>     <tr>         <th>patient's name</th>         <th>address</th>         <th>email-id</th>         <th>mobile</th>         <th>age</th>         <th>gender</th>         <th>actions</th>         <th>created</th>     </tr>  <!-- here's loop through our $posts array, printing out post info -->      <?php foreach ($posts $post): ?>     <tr>         <td><?php           echo $this->html->link(                     $post['patientslist']['patients_name'],                     array('action' => 'view', $post['patientslist']['id'])                 ); ?></td>         <td>             <?php                echo $post['patientslist']['address'];             ?>         </td>         <td>             <?php                echo $post['patientslist']['email'];             ?>         </td>         <td>             <?php                echo $post['patientslist']['mobile'];             ?>         </td>         <td>             <?php                echo $post['patientslist']['age'];             ?>         </td>         <td>             <?php                echo $post['patientslist']['gender'];             ?>         </td>         <td>             <?php                 echo $this->form->postlink(                     'delete',                     array('action' => 'delete', $post['patientslist']['id']),                     array('confirm' => 'are sure?')                 );             ?>             <?php                 echo $this->html->link(                     'edit', array('action' => 'edit', $post['patientslist']['id'])                 );             ?>         </td>         <td>             <?php echo $post['patientslist']['created']; ?>         </td>     </tr>     <?php endforeach; ?>  </table>   </div>   <div id="tabs-3">    </div> </div> 

in controller

<?php class dashboardscontroller extends appcontroller {     public $components = array('session');      public function index() {       $this-> loadmodel('patientslist');         $this->set('posts', $this->patientslist->find('all', array('conditions' => array('patientslist.user_id' => $this->auth->user('id')))));        }       public function view($id) {            $this-> loadmodel('patientslist');         if (!$id) {             throw new notfoundexception(__('invalid post'));         }          $post = $this->patientslist->findbyid($id);          if (!$post) {             throw new notfoundexception(__('invalid post'));         }         $this->set('post', $post);              }             public function add() {                  $this-> loadmodel('patientslist');     if ($this->request->is('post')) {         //added line         $this->request->data['patientslist']['user_id'] = $this->auth->user('id');         if ($this->patientslist->save($this->request->data)) {             $this->session->setflash(__('your post has been saved.'));             return $this->redirect(array('action' => 'index'));         }     } }    /*  public function add() {         if ($this->request->is('post')) {             $this->post->create();             if ($this->post->save($this->request->data)) {                 $this->session->setflash(__('your post has been saved.'));                 return $this->redirect(array('action' => 'index'));             }             $this->session->setflash(__('unable add post.'));         }     }     */     public function edit($id = null) {          $this-> loadmodel('patientslist');     if (!$id) {         throw new notfoundexception(__('invalid post'));     }      $post = $this->patientslist->findbyid($id);     if (!$post) {         throw new notfoundexception(__('invalid post'));     }      if ($this->request->is(array('patientslist', 'put'))) {         $this->patientslist->id = $id;         if ($this->patientslist->save($this->request->data)) {             $this->session->setflash(__('your post has been updated.'));             return $this->redirect(array('action' => 'index'));         }         $this->session->setflash(__('unable update post.'));      }      if (!$this->request->data) {         $this->request->data = $post;     } } public function delete($id) {      $this-> loadmodel('patientslist');     if ($this->request->is('get')) {         throw new methodnotallowedexception();     }      if ($this->patientslist->delete($id)) {         $this->session->setflash(             __('the post id: %s has been deleted.', h($id))         );         return $this->redirect(array('action' => 'index'));     } } public function isauthorized($user) {      $this-> loadmodel('patientslist');     // registered users can add posts     if ($this->action === 'add') {         return true;     }      // owner of post can edit , delete     if (in_array($this->action, array('edit', 'delete'))) {         $postid = $this->request->params['pass'][0];         if ($this->patientslist->isownedby($postid, $user['id'])) {             return true;         }     }//       return parent::isauthorized($user); } } ?> 

here doing code when add patient clicked popup open , add details


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -