0

I wanna have three types of Events on my website. All three types of events have common fields such as: name, date, location, time, host, price.. and many more.

Now each event type has few extra fields that do not apply to other events types.

It is very important requirement in UI administration form not to show fields that do not apply to a specific event type.

I was considering the idea of creating 3 separate Content types (one for each Event type), but somehow I feel this is not the best way to go since there is a lot of common elements.

Any suggestions?

4

If the content types share the majority of fields, it makes sense to keep them as a single content type.

I'd suggest adding a field for "Event type" or similar to record what sub-type of Event the content is and perhaps group the additional fields in fieldsets.

You can then show/hide the additional relevant fields with hook_field_attach_form (or equivalent) by setting '#access' => FALSE on the relevant field.

If you don't mind showing the fields to the user, you could also use a module like conditional_fields (D7 dev works ok)

  • Thank you David! While your solution is generally right, in my case it would not be worth doing it since I have many fields to hide. That said I'm gonna handle it as 3 independent types just to save some time since the project's budget is pretty limited. – Antonio Oct 29 '13 at 13:48
1

If you want to create three different content type for the events, then you can add common fields in one content type and then can add existing field in other content type as below.

  • Go to Administration -> Structure -> Content types
  • Click on "Manage fields" link in row of content type
  • In the "Add existing field" section, select the your field from in "select an existing field" drop box and save the form.

I also prefer the solution which is suggested by David, but if I need to add multiple condition to hide other fields, then creating different content type would be easy solution.

  • Thank you Jayendra! This was my first idea but I think David's solution is the right one. Just in favour of shorter development time, I will pick my original idea and also what you suggested here. – Antonio Oct 29 '13 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.