- 🇫🇷France mably
I can confirm that this still doesn't work as we are comparing two different values :
In the PHP code we are setting this in the
fieldFormElement
of theTextFieldCounterWidgetTrait
:$element['#attributes']['data-field-definition-id'] = $field_definition_id; $element['#attached']['drupalSettings']['textfieldCounter'][$key]['key'][$delta] = $key;
With
$key
and$field_definition_id
having potentially two different values.And then we are comparing them back in
textfield_counter.js
:$.each(settings.textfieldCounter, function (settingsIndex, fieldSettings) { var wrapperElement = $(errorElements[elementIndex]); if (fieldSettings.preventSubmit && settingsIndex === wrapperElement.find(".textfield-counter-element:first").data("field-definition-id")) { e.preventDefault();
And it some cases, when used in a paragraph for example, they don't match and the submit is not blocked.
- 🇮🇳India divyansh.gupta Jaipur
Hello @andriyun,
But I cannot reproduce the form submission error as it is working fine for me and showing me a error and my form is not submitting if i exceed the count limit. - 🇫🇷France mably
@divyansh.gupta try adding a multi-valued reference field to a node pointing to a paragraph containing a text field with a counter.
Then create a new instance of that content and add a paragraph with the text field exceeding the authorized length.
You will see that you can submit the form without triggering the javascript preventDefault.