3

I want to add 3 fields to my articles:

  • repeatable (boolean)
    • unlimited values for repeat_date and repeat_comment

I created the fields and with fields dependency I made the it possible that repeat_date and repeat_comment only appear if repeatable is checked. I can also create an unlimited number of values for repeat_date and repeat_comment.

But these 2 fields are independet of another. I could create 2 values of repeat_date entries and 4 values of repeat_comment. Also those fields appear separate when editing articles.

How can I combine those 2 fields and have unlimited values for this combined fields?

2 Answers 2

3

You can wrap the fields in a Paragraph with the paragraphs module. I.e. create a new paragraph type, repeatable_date, with two fields: date and comment. Then add a new paragraphs reference field to your article and set cardinality to unlimited. This will allow you to add unlimited repeatable date items, each with date and comment.

Or you can create a new custom field type that has a date field and a comment field. This is more difficult to do, but may be preferable if the paragraphs route doesn't suit you. See How to create a new field type for details.

0

In the end I used the field collection module since I had it already installed. I created such collection containing 2 fields: repeat_date and repeat_comment. Then I made the collection itself unlimited repeatable.

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.