In Drupal 8 I want to create content type for custom homepage slideshow so user can add image or link to video provider, but not both per node. For now I have content type with both fields, and in block plugin i give advantage on video field, so if video field is not empty he is displayed in slider, but if video field is empty image is displayed instead of video.

Any idea how to add checkbox so when user pick between video and image option in form will be displayed only one field to populate?

  • 1
    See the States API example in the Examples module. – Patrick Kenny Nov 18 '17 at 4:01
  • @PatrickKenny thanx for help, I find working solution using "Conditional Fields" module, but I dont know is this best solution and how this will affect on site performance. – StevanRS Nov 18 '17 at 4:44
  • In my experience (on D7), Conditional Fields is a rather buggy module and you have to test very carefully. It can also break other modules. As evidence, consider that the module is STILL in alpha for D7 even though Drupal 8 has been out for a couple years. So I would write the code yourself if you can. – Patrick Kenny Nov 18 '17 at 5:29
  • This seems easily solvable with just Paragraphs and no conditional fields or form altering. Create two paragraph types to represent heroes and on the node type, only allow one Paragraph with the option of both types. Problem solved. – Kevin Nov 18 '17 at 18:08

Your Answer

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

Browse other questions tagged or ask your own question.