govCMS / GovCMS7

Current stable release of the main Drupal 7 GovCMS distribution, with releases mirrored at https://www.drupal.org/project/govcms
https://www.govcms.gov.au/
GNU General Public License v2.0
112 stars 76 forks source link

Database Configuration - required fields prevent form submission #3

Closed paulkilla closed 8 years ago

paulkilla commented 9 years ago

Posted by tomz0r on July 14, 2015 at 4:13pm

/install.php?profile=govcms&locale=en

Having required="true" on the hidden form input fields is preventing the form from submitting. When you select MySQL as your database and fill in all the visible required fields, you also have to fill in dummy data in the PostgreSQL fields as well to be able to continue to the next step.

required_fields

typhonius commented 9 years ago

I'm not able to recreate this. This needs to be tried on a modern browser without extensions running to verify.

tomgibson commented 9 years ago

Issue is caused by HTML browser form validation.

Produced on:

Telling me to fill in the hidden PostgreSQL on Firefox when clicking submit: firefox_html5_validate

cannod commented 9 years ago

Just also tried to install govcms and had the same problem. Firefox on linux mint. As noted workaround was to just to fill in the postgreSQL fields even though I am using MySQL.

typhonius commented 9 years ago

Reopening this issue as it seems more widespread than first thought. From any of the affected users, is this govCMS specific or do you also experience this installing Drupal minimal/standard profiles.

seanhamlin commented 9 years ago

The module https://www.drupal.org/project/accessible_forms adds in the HTML5 required attribute, this looks like the cause of the issue. Perhaps a simple solution is to make the the PostgreSQL fields not mandatory (through hook_form_FORMID_alter).

typhonius commented 9 years ago

Would this module be active during site install? Does Drupal boot all modules prior to anything being installed? If that's the case we should probably also decide whether this is a module bug.

seanhamlin commented 9 years ago

You see the red "(mandatory)" in the screenshot - I believe the module accessible_forms does this.

pandaskii commented 9 years ago

In themes/govcms/govcms_zen/template.php line #205 it has:

$variables['element']['#attributes']['required'] = 'true';

Which adds the required="true" attribute

All browsers except Safari will respect this attribute to prevent the from from submitting

A simple fix could be in install.js, add:

for(var f=document.forms,i=f.length;i--;)f[i].setAttribute("novalidate",i)

Which will only disable browser's form validation during installation. All other form validations after installation are not affected.

typhonius commented 9 years ago

Should we also consider a template.php option instead of js?

/**
 * Adds accessibility attributes.
 */
function govcms_zen_preprocess_aria_invalid(&$variables) {
  if (!empty($variables['element']['#required']) && !drupal_installation_attempted()) {
    $variables['element']['#attributes']['required'] = 'true';
  }
  if (isset($variables['element']['#parents']) && form_get_error($variables['element']) !== NULL && !empty($variables['element']['#validated'])) {
    $variables['element']['#attributes']['aria-invalid'] = 'true';
  }
}
typhonius commented 9 years ago

The reason I was not able to replicate this before was because I do not have php pgsql drivers. When I remove the autofilled field from the SQLite settings, then attempt to proceed with MySQL settings only I see the issue.

The issue is not observed when commenting out line 205 in template.php of govcms_zen (thanks @jozhao)

aleayr commented 9 years ago

Do we have an agreed approach to this? Either the addition in the code @typhonius posted above, or commenting out/removing the line?

teamglenny commented 9 years ago

Is this still a thing, lads?

pandaskii commented 9 years ago

My 2 cents

@typhonius Please commit your solution ASAP :+1:

fiasco commented 9 years ago

Can someone test #92 ?