⚠ 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

"Add" not work



BadRequest

BadRequest
  • profile picture
  • Member

Posted 08 January 2016 - 18:08 PM

Hi, this library it's very very powerful!! Congrats! 

 

Ok, i have follow the manual for install it, work all fine but when i try to add a item coming out this message: {"success":false}

 

The function where i use Grocery Crud is:

public function news() {
        $this->grocery_crud->set_table($this->config->item('db_prefix', 'fantauction') . $this->config->item('news', 'fantauction') . $this->config->item('db_suffix', 'fantauction'));
        $this->grocery_crud->set_subject('News');
        $this->grocery_crud->required_fields('autore', 'titolo', 'testo');
        $this->grocery_crud->fields('autore', 'immagine', 'titolo', 'testo');
        $this->grocery_crud->display_as('aut_modifica','Autore modifica');
        
        $this->grocery_crud->callback_column('autore', array($this,'_id_to_username'));
        $this->grocery_crud->callback_column('aut_modifica', array($this,'_id_to_username'));

        $this->grocery_crud->callback_add_field('autore', array($this, '_callback_autore'));
        $this->grocery_crud->callback_add_field('testo', array($this, '_callback_testo'));

        $this->grocery_crud->callback_before_insert(array($this,'_checking_pre_insert'));
        
        $this->grocery = $this->grocery_crud->render();

        $this->_render_view('admin/news', false, $this->grocery, true);
    }

And the callback function are:

public function _id_to_username($value,$row) {
        return $this->ion_auth->user($value)->row()->username;
    }
    
    public function _checking_pre_insert($post_array) {
        $post_array['autore'] = $this->ion_auth->user()->row()->id;
        return $post_array;
    }

    public function _callback_autore() {
        
        $string = '<input type="text" value="' . $this->ion_auth->user()->row()->username . '" name="autore" disabled>';
        return $string;
    }

    public function _callback_testo() {
        return '<textarea tows="8" cols="80" maxlength="1000" name="testo" ></textarea>';
    }

Where can be the error in the code?

 

And other thing, in Add and Edit mode the button "Save and go back to the list" so "Update and go back to the list" not work, when i click them not do nothing... same a blank button... Suggest also for this?

 

Thanks a lot!