- Issue created by @coaston
- π«π·France lazzyvn paris
This will never work I think because the paragraphs widget do nothing, it just render the entity form standard. widget pargraphs table rewrite all html field into a table, codtional field based on field selector to hide or show, DOM is changed. why don't you write a small js script in your form, it's faster than waiting support :)
- πΈπ°Slovakia coaston
I would like to learn and see an example.
Can you be so kind and provide any example I am using also Asset Injector module so I can put the code right there but if you can help me with some example I can adjust it to my needs.
Thank you
- πΈπ°Slovakia coaston
Finally. Pasting code if anyone else would need the same.
Here is my code, the first function triggers red *
and the second one alert that field is empty.(function ($) { Drupal.behaviors.markFieldRequired = { attach: function(context, settings) { console.log("JavaScript code is loaded"); var fieldName = "edit-field-mandatory-0-value"; console.log("fieldName:", fieldName); $("input[name='" + fieldName + "']", context).attr("required", "required"); $("label[for='" + fieldName + "']", context).append("<span class='form-required' title='This field is required.'>*</span>"); } }; })(jQuery); (function($) { $(document).ready(function() { $('#edit-submit').click(function(event) { // Get the value of the field. var field_value = $('#edit-field-mandatory-0-value').val(); // Check if the field is empty. if (field_value === '') { // If the field is empty, prevent the form from being submitted. event.preventDefault(); alert('Please fill in the mandatory field called "Mandalorian".'); } }); }); })(jQuery);