⚠ 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

Many-to-Many question



xckon
  • profile picture
  • Member

Posted 01 March 2013 - 03:34 AM

Hi, im new a grocery, is there any plugin or somenthing to do the next?
 
Got 3 tables:
 
Product
-------
  + Id
  + Price
 
Lang
----
  + Id
  + Name
 
Product_Lang
------------
  + Id (PK)
  + Product_id (FK to Product.id)
  + Lang_Id (FK to Lang.id)
  + Name
  + Decription
 
How can i make, that grocery displays a {name}/{description} input text for each item into Product_Lang, on the edit or add form?? Now with the many to many relation, only shows one input.

davidoster
  • profile picture
  • Member

Posted 03 March 2013 - 10:49 AM

Within your set_relation_n_n function call use just that "{name} {description}".


xckon
  • profile picture
  • Member

Posted 05 March 2013 - 01:43 AM

Sorry, maybe i explained it wrong, what i need to do, is displaying one input for Product_Lang.Name and another one for Product_Lang.Description, for each record in Lang, it's for an e-commerce site, using internationalization.
Is grocery capable of doing this, or i need to develop that custom feature myself without grocery?

davidoster
  • profile picture
  • Member

Posted 05 March 2013 - 09:42 AM

Ooo ok! Now I get it! Sorry.

I thought I had a solution but it was wrong.

Let me think of it...


davidoster
  • profile picture
  • Member

Posted 05 March 2013 - 10:11 AM

Can you print out your controller's code?

I don't fully understand how you implement this system.

For example, your product table has the id,price.

How do you insert the name/description of a specific product?

 

To be honest with you I would have changed your product table a little bit but this would help me a lot with the design.

 

table product

id,name,description,price 

(name, description here use a default let's say english name/description)

 

but by doing this then I could use a simple set_relation to show up the multilingual name/description from the product_lang table!

What do you think about this?

 

In essence what you have here is a Master(product) / Detail (product_lang) structure and this is not yet supported by GC library.

But you could achieve the same functionality like this.

 

REMEMBER you need to callback_before_insert / callback_before_update in order to update both the product table and the product_lang table!