Validate function firing on AJAX submit

Created on 6 February 2017, over 8 years ago
Updated 3 November 2024, 6 months ago

I have a multi-value reference (node) field. I'm using the inline_entity_form module on that field, and the field also has a validation function (from my module). The original problem was that, when clicking the "Add another item" button (which, as far as I can tell, posts back to the same form/URL via an AJAX call), my validation function was firing - and since the user hadn't completed the form, validation errors were being shown.

After researching it a bit, I read that to keep the form-level validation from running during an AJAX call, I should move the validation to the submit button(s). When I did that, I got the "Entity validation was skipped" error. Research on that error showed that, when submit-level validations are registered, the form-level validations don't get executed. Not sure why that would be.

Edit: the following was changed from the original post...

I moved the validation back to the form-level, and dug deeper. I noticed that the submit_handlers property of the form_state class cause the correct submit handlers to run based on AJAX vs. form submit (see screenshots). Why doesn't that happen with validation functions?

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡ΊπŸ‡ΈUnited States ExTexan

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.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    There has been no discussion here for 8 years so I am checking in to see if this is still a problem. Is it?

    I am setting the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Status changed to Closed: outdated about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Since there hasn't been a follow up going to close out for now. If still an issue please reopen.

    Thanks everyone!

Production build 0.71.5 2024