Jump to content


Many-to-Many question

set_relation_n_n many to many how to

  • Please log in to reply
4 replies to this topic

#1 xckon

xckon

    Newbie

  • Members
  • Pip
  • 2 posts

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.


#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 03 March 2013 - 10:49 AM

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


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 xckon

xckon

    Newbie

  • Members
  • Pip
  • 2 posts

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?


#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

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


Edited by davidoster, 05 March 2013 - 10:01 AM.

____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

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!


Edited by davidoster, 05 March 2013 - 10:16 AM.

____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr






Also tagged with one or more of these keywords: set_relation_n_n, many to many, how to

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users