⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Edit page only



Puskás Gábor
  • profile picture
  • Member

Posted 04 August 2015 - 06:47 AM

Hi!

 

I use the Grocery CRUD in my project.

I want use the Grocery Crud's edit page in my user space.

 

The edit page is looks good for able user editing her profile datas. But I don't know how do that.

 

Eg.: http://myproject.tld/profile is need to looks like this http://myproject.tld/profile/index/edit/321 but I want prevent the user switch back to the whole table look, and/or do anything other than save her datas.

 

Any idea?

 

 

 

 


marlaaragao
  • profile picture
  • Member

Posted 05 August 2015 - 12:58 PM

Hi!

 

Your links are not working. I did this in my project. You must unset the operations (at least the list and back to list with unset_list() and unset_back_to_list()). When you render, grocery will raise an exception saying that you don't have permission to access the list operation (the grid). So you can catch it and redirect to the edit form. Example:

        $crud = new Grocery_CRUD();
        $crud->set_table($this->_table);
        
        $crud->unset_list(); 
        $crud->unset_back_to_list();
        
        $crud->unset_delete();
        $crud->unset_add();
        $crud->unset_read();
        $crud->unset_export();
        $crud->unset_print();
        
        try {
            
            $output = $crud->render(); //this will raise an exception when the action is list

            $this->template->load('template', 'default_view', $output);
            
        } catch (Exception $e) {

            if ($e->getCode() == 14) {  //The 14 is the code of the error on grocery CRUD (don't have permission).
                //redirect using your user id
                redirect(strtolower(__CLASS__) . '/' . strtolower(__FUNCTION__) . '/edit/' . $theUserID);
                
            } else {
                show_error($e->getMessage());
                return false;
            }
        }