Default required fields on donation are missing.
The ability to hide such required fields was also implemented - for example to hide the required 'State' field.

Comments

berdir’s picture

Status: Needs review » Needs work
+++ b/salsa_donate_page/salsa_donate_page.moduleundefined
@@ -45,9 +45,39 @@ function salsa_donate_page_form($form, &$form_state, $donate_page, $view_mode) {
+  if (!empty($hidden_fields) && is_array($hidden_fields)) {
+    $keys = array_keys($required);
+    for ($i = count($keys)-1; $i >= 0; $i--) {
+      if (in_array($required[$keys[$i]], $hidden_fields)) {
+        unset($required[$keys[$i]]);
+      }
+    }

the is_array() check is IMHO unecessary.

The loop seems unecessarly complicated, why not a foreach ($required as $key => $field) {
// if hidden, unset
}
?

+++ b/salsa_donate_page/salsa_donate_page.moduleundefined
@@ -45,9 +45,39 @@ function salsa_donate_page_form($form, &$form_state, $donate_page, $view_mode) {
+      $form['Supporter_Info'][$field]['#type'] = 'hidden';

Use #access = FALSE instead, then the field won't be shown and it will also ignore the #required setting , so you wouldn't even have to do the first loop.

LukyLuke_ch’s picture

Status: Needs work » Needs review
StatusFileSize
new1.71 KB

Hmm, didn't know that removing elements inside a foreach does work, strange :)

berdir’s picture

Status: Needs review » Fixed

Thanks, commited.

Status: Fixed » Closed (fixed)

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