Jump to content


Little question about a n_n relation


  • Please log in to reply
8 replies to this topic

#1 dorulk

dorulk

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 30 November 2014 - 09: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:
 
modelo.JPG
 
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!

 

Attached Thumbnails

  • modelo.JPG


#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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.!!



#3 dorulk

dorulk

    Newbie

  • Members
  • Pip
  • 3 posts

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

1_add.JPG

 

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

2_dontsaveproducts.JPG

 

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

3-edit.JPG

 

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

4_edit-save.JPG

 

Thanks for your help



#4 dorulk

dorulk

    Newbie

  • Members
  • Pip
  • 3 posts

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!



#5 flip

flip

    Newbie

  • Members
  • Pip
  • 2 posts

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?



#6 voghDev

voghDev

    Member

  • Members
  • PipPip
  • 20 posts

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



#7 flip

flip

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 07 April 2015 - 04:46 PM

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



#8 voghDev

voghDev

    Member

  • Members
  • PipPip
  • 20 posts

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.



#9 voghDev

voghDev

    Member

  • Members
  • PipPip
  • 20 posts

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.grocerycr..._a_relation_n_n

 

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users