2

I am working with Drupal 8, and have a custom post type called: chapter. This content type is connected with a taxonomy term called: Book.

Now, I have a field called: number, for specifying the chapter one, two or three. this field should be unique. For example, if I say chapter 1 I can not repeat it ever again in the same book, but I can upload the chapter 1 for another book. I also can upload all the chapters for the same book in a different order.

So the rule is: Just add a unique chapter number per book.

The final goal is to create a view and be able to order my chapters by the number.

Do I have to use the rules module for that? Or maybe, there is a better approach?.

2

You can implement a custom validation constraint and a hook_entity_bundle_field_info_alter to set the new constraint to your field.

Check: https://www.drupal.org/docs/8/api/entity-validation-api/providing-a-custom-validation-constraint

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.