⚠ 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

Little question about a n_n relation



dorulk
  • profile picture
  • Member

Posted 30 November 2014 - 21:23 PM

Hi,  I'm having a little problem with the n_n relation, when I add a new register to the app, this don't save the "products", (all other  information yes), but if I update this register I can save succesufully the "products"

 

this is the model:
 
[sharedmedia=core:attachments:865]
 
and this is my code:
 
 $crud = new grocery_CRUD();
 
        $crud->set_table('requisicion');
             
        $crud->set_subject('Requisición');
        
        $crud->set_relation_n_n('productos', 'requisicion_has_producto', 'producto', 'requisicion_id_requisicion', 'producto_id_producto','nom_producto','desc_productoxreq');
              
        $crud->set_relation('id_prioridad','prioridad','nom_prioridad');
          
        $crud->set_field_upload('adjunto','assets/uploads/files');
        
        $crud->fields('id_requisicion','id_prioridad','productos','des_requisicion','adjunto');
 
        $output = $crud->render();
 
        $this->_example_output($output);
Can anyone help me with this problem?

 

 

Best Regards!

 


Amit Shah
  • profile picture
  • Member

Posted 01 December 2014 - 02:31 AM

what are you trying to achieve in here? Are you trying to create new product or you saying you trying to add products to requisition? What is not getting saved ? ? products in relation table .. or details in product table... Sorry need to make stuff more clearer in order to reach to solution.!!


dorulk
  • profile picture
  • Member

Posted 01 December 2014 - 02:52 AM

Hi Amit, well 

 

 First I try to add a new requisition with two products (but this not work well), but when I edit this new requisition this work fine and new products are stored into the requisiton. I'm sending more pictures for explain, because my english vocabulary it's not good.

 

1.- New requisition and I try to add two products

[attachment=869:1_add.JPG]

 

2.- I can´t store products in a new requisition

[attachment=868:2_dontsaveproducts.JPG]

 

3.- If i edit the same requisition and add again the products

[attachment=867:3-edit.JPG]

 

4.- ...the products was storing fine in the requisition

[attachment=866:4_edit-save.JPG]

 

Thanks for your help


dorulk
  • profile picture
  • Member

Posted 16 December 2014 - 05:00 AM

Solved: It's a problem with the restriction in my db model, I deleted this and voila, all work fine!, thanks!


flip
  • profile picture
  • Member

Posted 30 March 2015 - 08:09 AM

Solved: It's a problem with the restriction in my db model, I deleted this and voila, all work fine!, thanks!

Dorulk I have the same problem, what restriction in db model, how do you solved it?


voghDev
  • profile picture
  • Member

Posted 30 March 2015 - 10:43 AM

I have the same problem. I have Article that has 1..N Categories, and I can't store Categories when adding, but yes when editing.

 

Please post details about the solution you found. (DB restriction, etc).

 

Thanks


flip
  • profile picture
  • Member

Posted 07 April 2015 - 16:46 PM

I deleted the constraint (key and foreign key) but when adding insert '0' in foreign key


voghDev
  • profile picture
  • Member

Posted 08 April 2015 - 11:10 AM

I deleted the constraint (key and foreign key) but when adding insert '0' in foreign key

 

Same here. I'm getting a 0 when adding, and correct value when editing.


voghDev
  • profile picture
  • Member

Posted 06 May 2015 - 08:07 AM

Hi again, still having the same issue after some research.

 

Can anyone post working code for table creation (SQL) + CRUD ?

 

Just like the one on the example:

 

http://www.grocerycrud.com/examples/set_a_relation_n_n

 

which seems to work adding/editing the 1..N field