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

1 Answer 1

3

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

0

Your Answer

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

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