This module works for the Name field (http://drupal.org/project/name) but I have a Field Collection field (http://drupal.org/project/field_collection) and 2 entity references fields (http://drupal.org/project/entityreference) which are all required.

It only forces the Name field to have a value before proceeding to the next step. I can leave field collection fields and entity reference fields blank and it will allow to submit the form. Since these are required fields, the form must have values for these fields before moving to the next step.

Thanks! Andrew

Comments

aaronbauman’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Issue summary: View changes

In fact, this module doesn't seem to do any validation between steps, even for core fields.
What's the point of ajaxifying if we're not performing any server-side logic on submit?

In fact, server-side validation doesn't even happen on the final submit.
I'm able to submit a node form without filling in any required fields.

This is a serious problem

aaronbauman’s picture

Priority: Normal » Critical
thijsvdanker’s picture

Please review https://www.drupal.org/node/1972616#comment-9502715.

It applies to the master branch!! of this project.

thijsvdanker’s picture

fox_01’s picture

i have installed the 7.x-1.0-beta2 version and tried the example module and it stops on not filled required fields. so it works. but i have clientside validation enabled. is this module required here?

Algeron’s picture

In case anyone is struggling with getting validation to trigger on fieldable entities, allow me to share a day's worth of frustration and a workaround:

My setup

  • A multi-step EntityForm
  • Several field collections per step
  • A mix of custom validation and field validation
  • Step 1 contained 3 field collections and roughly 20 fields of varying types

Issues

  • On step 1 of the form, field validation wasn't triggered. Only the custom validation was being resolved.
  • Upon failed validation, all fields were empty.
  • "Save draft" did not work for step 1.
  • If the user made it to the 2nd step and clicked the Previous button, all validation seemed to work as normal on step 1. Except, when validation failed again on step 1, it didn't apply field validation on the 2nd and subsequent attempts.
  • Upon failed validation at this point, field values kept reverting back to what they were like when the user went from step 2 to step 1.
  • AJAX/refresh made no difference (except that AJAX also broke field label translation). Neither did explicitly setting the $form_state['values'] as done in _field_group_ajaxified_multipage_form_submit.

Workaround

For reasons that are beyond me, field validation only acts on "simple" fields when the user is on step 1. I was able to restructure the steps in such a way that the first step only had a simple radio button list. I still had to set its #default_value in a hook_form_alter, since neither the field configuration nor the drafted values were sticking.

As for the values that kept disappearing when validation failed: adding the following snippet to my validation function fixed the issue:

$errors = form_get_errors();
  if (!empty($errors)) {
    // Only rebuild when there are errors, since this also seems to prevent the form
    // from advancing to the next step.
    $form_state['rebuild'] = TRUE;
  }

Versions

  • Drupal 7.39
  • Field Group Ajaxified Multipage 7.x-1.0-beta2
  • Entityforms 7.x-2.0-rc1
  • Field Group 7.x-1.4
sgurlt’s picture

Status: Active » Closed (duplicate)

This is a duplication of: https://www.drupal.org/node/1972616
My patch #46 there should fix that.