0

I have a contract content type on my Drupal 8 site, and I would like to use the same content type for multiple different types of contracts.

95% of the fields are common for all types (contact information, prices etc.), but there are some fields specific to a contract type.

I was going to do this simply by having a field indicating the contract type, and then using form alter etc. to hide/disable fields, and set other fields required where necessary.

I'm sure there's a much better way to do this.. What would be the best approach here?

3
  • Well, in this case it sounds like Nodes are not the correct entity type for you. Instead you need a Contract entity type, with different bundles (types) for each of your contract types. New entity types can be created through code, or you can try ECK (drupal.org/project/eck) though it appears to be in Alpha version for Drupal 8.
    – Jaypan
    Dec 2, 2019 at 20:59
  • Sounds like Contract is an entity type and the types of contracts would be bundles of that. Would advise not using ECK, just generate them with Drupal Console or coding them. Would not advise trying to contextualize one type by showing/hiding fields, etc.. would think about the data model a bit more IMO.
    – Kevin
    Dec 2, 2019 at 22:53
  • Creating a contract entity type worked great. Thanks.
    – dxo
    Dec 5, 2019 at 14:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.