0

Is ExpressionEngine capable of handling HABTM (has and belongs to many) relationships, even if it's with a plugin?

Basically, I have two channels: recipes and ingredients. A user needs to be able to create a recipe by assigning entries from my Ingredients channel, but when adding an ingredient they also need to specify additional data such as quantity. Is this possible?

Martin Bean
  • 38,379
  • 25
  • 128
  • 201

1 Answers1

1

Your answer lies in two indispensable EE add-ons by Pixel and Tonic: Playa and Matrix.

Playa is a many-to-many relationship fieldtype and module.

Matrix is a fieldtype which allows a single field to contain multiple rows of multiple predefined columns of data, each column of which can be a different fieldtype (including Playa).

So in your case, you'd have your standard Ingredients channel, then in your Recipes channel, you'd have an Ingredients field, which would be a Matrix fieldtype. In your Matrix field, you'd have one Playa column which displayed a dropdown of entries from your Ingredients channel, and another column that was a simple text input set to Integer for the quantity.

Derek Hogue
  • 4,589
  • 1
  • 15
  • 27