Fix Required fields to really not be required

Created on 8 January 2019, about 5 years ago
Updated 12 February 2024, 12 days ago

Title is hidden and required. Form will not submit without a title value. I'm not clear on why this would happen - but pretty clearly I would not want to bulk edit node titles, however the Title field is right there with a required value and the form will not submit without a value. I don't know what might be causing this and am surprised that others are not experiencing this.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States brooke_heaton

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇵🇭Philippines mjgruta

    Patch #29 doesn't work with Drupal Commerce. It's still asking for variations SKU and Price.

  • 🇺🇸United States hyperlinked San Jose, CA

    @mjgruta, go into the product types configurations and check the "Allow more than one variation" checkbox. That will move the SKU and Variant Title off of the primary product entity form and allow you to perform a bulk edit.

    There's also a workaround you can use in a pinch that works if any field doesn't play well with the patch.

    Select the SKU and Price fields and enter a value in for each field. Now uncheck those fields as fields you want to edit. Whatever you just entered will not be applied. They'll remain filled in so you'll be able to submit the form, but the values will be ignored.

  • 🇺🇸United States aitala

    HI,

    Patch #29 allows me to at least post the form but its still giving me an issue with a specific required field.

    The field I want to change (Company) and the field which tosses the error (Review Author) are both entity reference fields. (Note: I do no want to change the Review Author field.). I have other required fields which are not throwing errors.

    Thanks,
    Eric

  • 🇩🇪Germany kreatIL

    @aitala: From your screenshot, one could assume that you ticked "Review Author" before submitting the form. Even if I don't draw that conclusion, I would like to point out that the tick must of course not be set for required fields whose values you don't want to change.

  • 🇺🇸United States aitala

    HI,

    I did not tick the 'Review Author' box before I submitted the form.

    I ticked it which revealed the "Review Author (value 1) field required." notice otherwise all you see is the '1 error has been found: Review Author (value 1)' notice with no explanation. The only value I am trying to change is the Company field.

    Eric

  • 🇲🇾Malaysia ckng

    Patch #30 is not working for me too. Have a simple content type with required image field, but trying to bulk update a boolean field, getting error "Image field is required.".

  • 🇫🇮Finland ronttizz Helsinki

    Patch #30 did not solve the problem, it allows the form to be sent but title and URL are still required. Any updates on this one?

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 7.3 & MySQL 5.7
    last update 8 months ago
    Composer error. Unable to continue.
  • 🇯🇴Jordan n.ghunaim Amman - Jordan

    I updated the patch to work for nested form elements, change the required values to false, and remove validateRequired callbacks.
    Please review the new patch.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    8 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 7.3 & MySQL 5.7
    last update 8 months ago
    Composer error. Unable to continue.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 8 months ago
    8 pass
  • 🇩🇪Germany kreatIL

    Patch #45 is working in my case.

  • 🇨🇿Czech Republic David Urban

    Patch #45 is working in my case.

  • First commit to issue fork.
  • 🇭🇷Croatia portulaca

    Patch #45 isn't working for me when Address field has some required fields.

    If I make them optional, then the updates for other fields go through, even when the Alt field of an image field is kept as Required.

  • Status changed to Needs work 4 months ago
  • 🇦🇲Armenia arthur.baghdasar

    Doesnt work with nested paragraph required fields.

  • 🇧🇪Belgium falc0

    Patch #45 doesn't work for me. It gives me this error:

    TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 436 of modules/contrib/views_bulk_edit/src/Form/BulkEditFormTrait.php).

    The problem that triggers the error is that the values are no longer in the $form_state->getValues() but I do find them in the input.

    $field_data = $form_state->getValue([$entity_type_id, $bundle]);

    So if I replace this line with this, it works but I don't think this is a good solution.

    $field_data = $form_state->getValue([$entity_type_id, $bundle]);
            if (!isset($field_data['_field_selector'])) {
              $input_data = $form_state->getUserInput();
              $field_data = $input_data[$entity_type_id][$bundle];
            }
  • 🇧🇪Belgium falc0

    For me patch #29 works, except for some entity reference fields that are still required. I added some code to the patch to fix my use-case.

  • First commit to issue fork.
  • Provided an update which uses the States API to switch the #required fields off/on based on whether the field was ticked or not. And recursively disables the #required and #access to fields which the user is uninterested in editing.

    It should also work with various other field widgets such as Paragraphs or Media Library.

    I believe the initial novalidate approach isn't advisable since you lose all client-side validations.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update about 2 months ago
    8 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update about 2 months ago
    1 pass, 4 fail
  • Addressed a flaw in logic where it's possible to accidentally flag a field as "required" as long as it had a #element_validate or #validate property.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update about 2 months ago
    8 pass
  • Addressed an oversight in the #56 patch.

  • Status changed to Needs review 27 days ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 27 days ago
    8 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 27 days ago
    8 pass
  • 🇯🇴Jordan Qusai Taha Amman

    Thank you this is working with me

  • 🇨🇦Canada JayDarnell Guelph, Ontario

    Patch #57 worked for me

Production build https://api.contrib.social 0.61.6-2-g546bc20