⚠ 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

n_n relation form



Smilie

Smilie
  • profile picture
  • Member

Posted 17 October 2013 - 20:05 PM

Hi,

I got my n_n relation working like a charm:

http://i.imgur.com/DmhviZD.png

 

My "problem" is that I want to use the other form control, like demonstrated in the example here: 

http://i.imgur.com/dDAaK28.png

 

(http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n)

 

How go I go on about this?

 

My code:

 

$crud = new grocery_CRUD();
 
        $crud->set_table('users')
            ->set_subject('User')
            ->columns('username','id', 'email', 'active')
            ->display_as('username','Username')
            ->display_as('id','Id')
            ->display_as('email','Email')
            ->display_as('active','Active');
 
        $crud->callback_before_delete(array($this,'protect_default'));
        $crud->callback_before_insert(array($this,'encrypt_password_callback'));
        $crud->callback_before_update(array($this,'encrypt_password_callback'));
        $crud->callback_edit_field('password',array($this,'set_password_input_to_empty'));
        $crud->callback_add_field('password',array($this,'set_password_input_to_empty'));
        $crud->field_type('salt', 'hidden');
 
        $crud->set_relation_n_n('groups', 'user_group_relations', 'usergroups', 'user_id', 'group_id', 'name');
 
        $crud->set_rules('username', 'Username', 'trim|required|min_length[3]|max_length[12]|xss_clean');
        $crud->set_rules('email', 'Email', 'required|valid_email');
        $crud->unset_print();
        $crud->unset_export();
        $crud->unset_delete();
        $crud->fields('username', 'email','groups', 'active', 'password', 'salt');
        $crud->required_fields('username', 'email', 'active');
 

briggers

briggers
  • profile picture
  • Member

Posted 18 October 2013 - 07:54 AM

Hi Smilie,

 

This question is answered in thread /topic/2057-add-form-layout-question/

 

It's the 7th parameter in $crud->set_relation_n_n