Problem/Motivation and Proposed resolution

Screenshot on 10.18.2013 at 12.50.35 PM.png

we can see on this is screen what a day field is filled correctly, but it is marked as wrong, so only month and year fields should be to marked
this patch allow make a validation a more clearly, like screen

Screenshot on 10.18.2013 at 12.47.38 PM.png

This changes was also supported into Webform Validation module (https://drupal.org/node/1913494#comment-7979391)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spheresh’s picture

Status: Active » Needs review
FileSize
1.04 KB
spheresh’s picture

Title: Marked fieldshilud be seporated » Marked fields should be separated
spheresh’s picture

Issue summary: View changes

Related issue

spheresh’s picture

Issue summary: View changes

aslo

spheresh’s picture

Title: Marked fields should be separated » Validation of multi-valued elements of webforms
Category: Feature request » Task
Issue summary: View changes
quicksketch’s picture

Thanks, this seems like a reasonable improvement. The code needs to be improved slightly for translation purposes. We shouldn't be trying to reassemble the word day/month/year from a non-translatable source. Instead we should give each field an internal label, or pull it from existing properties (like maybe #attributes['title']).

spheresh’s picture

Assigned: Unassigned » spheresh
Status: Needs review » Needs work

Hi @quicksketch. Thank you for response. I think you are right. I will take a little bit of time for research the question and make some improve, although an internal label sounds good.

spheresh’s picture

Status: Needs work » Needs review
FileSize
1.88 KB
quicksketch’s picture

Title: Validation of multi-valued elements of webforms » Provide more specific error messages for date components
FileSize
1.77 KB

Thanks @spheresh! While testing your patch I found that it would skip the remainder of the validation (such as invalidating Feb 30) because a "return" was being called in all situations:

    // Check if the user filled the required fields.
    if($element['#required'] && count($errors) >= 3){
      form_error($element, t('!name field is required.', array('!name' => $element['#title'])));
      return;
    }
    else {
      foreach ($errors as $field_type) {
        $element_name = implode('][', array_merge($element['#parents'], (array) $field_type));
        // It will be marked only wrong items of fields, unlike to the form_error function that marks all items for the date field.
        form_set_error($element_name, t('!name field is not filled.', array('!name' => $element[$field_type]['#title'])));
      }
      return;
    }

I made the "else" an "elseif (count($errors))" to make it so the return is only called if there's a missing value.

I've committed this patch to the project. Please let me know if you encounter any issues.

quicksketch’s picture

Status: Needs review » Fixed
FileSize
1.86 KB

Sorry this version was actually committed. The previous version has an issue with not throwing an error on a completely empty required date.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fenstrat’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Assigned: spheresh » fenstrat
Status: Closed (fixed) » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed 2a37061 and 12cf059 to 8.x-4.x. Thanks!

  • Commit 1a00a5e on 8.x-4.x by fenstrat:
    Issue #2114983 by spheresh, quicksketch: Provide more specific error...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.