Dependency using body as target results in "An invalid form control with name='body[0][value]' is not focusable." with ckeditor enabled

Created on 29 July 2018, almost 6 years ago
Updated 30 April 2024, about 2 months ago

Steps to reproduce:

  • Create a node with a (not required) body and a boolean checkbox.
  • Add a dependency so that if the box is checked the body is required.
  • Submit with box check and an empty body.

What will happen is the form simply won't submit with no apparent error. Upon inspection of the console, you'd find this:
An invalid form control with name='body[0][value]' is not focusable.
The problem is that textarea has been hidden and replaced by the WYSIWYG. conditional_fields needs to be able to detect that and get the correct element. conditional_fields does supply a field for a custom jquery selector for the control field, but not the target, and even if it did, I wouldn't know what to pick.

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Javascript

Created by

πŸ‡ΊπŸ‡ΈUnited States seanr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ͺπŸ‡ΈSpain rcodina

    Patch on #7 works for me. In my case I have a required and a disabled condition and now both works. Thanks @gaurav_manerkar.

  • πŸ‡ͺπŸ‡ΈSpain saganakat

    The patch didn't work for me. I keep getting the same error, and now when I check and uncheck the checkbox the textarea is cloned.

    My current environment:
    - Drupal 9.5.7
    - Conditional Fields 4.0.0-alpha2
    - Admin Theme Gin 8.x-3.0-rc2

    Steps to reproduce:

    • Install module with composer
    • Apply the patch with composer
    • In content type article add a new boolean field
    • Add new conditonal rule in manage dependecies: When checkbox is checked the body is required
    • Try to create new article node
  • Status changed to Needs work about 1 year ago
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    130 pass
  • Here's the proof about the reason for such issue: An invalid form control with name='' is not focusable

    To solve this we should do textareas optional, because it is hidden by ckeditor.

    I've attached patch for this.

  • πŸ‡΅πŸ‡ΉPortugal rfmarcelino

    #12 worked well for me

  • πŸ‡ΊπŸ‡ΈUnited States pbabin

    I think this is a core issue and not a conditional_fields error. https://www.drupal.org/project/drupal/issues/2722319 πŸ› s using Text Editor always fail HTML5 validation when "required" is added via #states Needs work

    We're running Drupal 10.2.5 and ran into this issue where we have a required rtf ckeditor 5 field dependent on if another field is checked. If checked, then rtf field is required. If not checked, then rtf field is not required. The issue appears if the conditions are met on the creation of a new node. I tried the #12 patch and it did not work. After recreating the conditional in a hook_form_alter the error was still there without the conditional_fields approach.

    After applying the core patch, the hook_form_alter code I was working on started working and the setup we have using conditional_fields also worked without the error.

Production build 0.69.0 2024