Jump to content


Additional Information in n2n

n2n

  • Please log in to reply
4 replies to this topic

#1 Ben85

Ben85

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 04 August 2018 - 10:26 PM

Hi All,

 

I just started using Grocery CRUD Enterprise with CodeIgnitor and I love it. First of all thanks for creating this awesome lib.

 

I successfully created a n2n relationship which is working great. But I would need to add some more information to the junctionTable. Its a connection between a user and a crew table where a crew can has multiple user or a user can has multiple crews. What I need to add is a timeframe from when to when the user will be on this crew, I already created two field "userincrew_from" and "userincrew_to".

 

Is there any way to let the user fill in those two information while editing the db entry?

$crud = $this->_getGroceryCrudEnterprise();
$crud->setSkin('bootstrap-v4');
$crud->setTable('Crew');
$crud->setSubject('Crew', 'Crews');
$crud->columns(['crew_name', 'company_id', 'user_id_crewboss', 'user_id_cook', 'user_id_geo', 'crewmember']);
$crud->displayAs('crew_name', 'Crewname');
$crud->displayAs('company_id', 'Company');
$crud->displayAs('user_id_crewboss', 'Crewboss');
$crud->displayAs('user_id_cook', 'Cook');
$crud->displayAs('user_id_geo', 'Geologist');
$crud->setRelation('company_id', 'Company', 'company_shortcut');
$crud->setRelation('user_id_crewboss', 'Users', '{user_firstname} {user_lastname}');
$crud->setRelation('user_id_cook', 'Users', '{user_firstname} {user_lastname}');
$crud->setRelation('user_id_geo', 'Users', '{user_firstname} {user_lastname}');
$crud->setRelationNtoN('crewmember', 'User_to_Crew', 'Users', 'crew_id', 'user_id', '{user_firstname} {user_lastname}');
$output = $crud->render();
$page = $page."/crews";
$this->view_output($data,$page,$output);

Thanks so much for you help,

Ben



#2 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 185 posts
  • LocationPhilippines

Posted 06 August 2018 - 12:04 AM

Hello!

 

Perhaps this could help: https://www.groceryc...ackBeforeInsert



#3 Ben85

Ben85

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 06 August 2018 - 11:16 PM

Hi Lara,

 

thanks for the link. After reading it I think that would work only to edit a field in the base table.

The field I want to edit is in the junction table. Since the keys are written there via GroceryCRUD I hope that it is possible to write even one more field into this table.

 

Thanks,

Ben



#4 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 185 posts
  • LocationPhilippines

Posted 07 August 2018 - 02:06 AM

Hi Ben!

 

Would it be a hassle if you create another GCRUD for the said values for user input?

Just a suggestion though.

 

:)



#5 Ben85

Ben85

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 15 August 2018 - 08:14 PM

Hi Lara,

 

sorry for the late answer.

To be honest it would be not optimal to have a second instance of GCRUD just for adding those two values. Especially since they are so connected to the crew table users would need to first create a crew and then add additional information in a second place.

 

Thanks for your help,

Ben







Also tagged with one or more of these keywords: n2n

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users