Skip to content
Snippets Groups Projects
Commit 1e05a73a authored by Lucas García's avatar Lucas García
Browse files

Merge branch 'feat/consent-field' into 'main'

Consent field

See merge request coopdevs/website/wp/wp-plugins/wpct-crm-forms!7
parents 7391e271 0d3863fa
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,6 @@ function wpct_crm_forms_parse_form_entry($entry, $form)
foreach ($form['fields'] as $field) {
if ($field->type === 'section') continue;
if ($field->type === 'consent') continue;
$input_name = $field->inputName
? $field->inputName
......@@ -20,6 +19,7 @@ function wpct_crm_forms_parse_form_entry($entry, $form)
: $field->label);
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
// composed fields
$names = array_map(function ($input) {
......@@ -37,7 +37,8 @@ function wpct_crm_forms_parse_form_entry($entry, $form)
foreach ($inputs as $input) {
$value = rgar($entry, (string) $input['id']);
if ($input_name && $value) {
$values[] = wpct_crm_forms_format_value($value, $field, $input);
$value = wpct_crm_forms_format_value($value, $field, $input);
if ($value !== null) $values[] = $value;
}
}
......@@ -60,6 +61,9 @@ function wpct_crm_forms_format_value($value, $field, $input = null)
try {
if ($field->type === 'fileupload' && $value && is_string($value)) {
return implode(',', json_decode($value));
} else if ($field->type === 'consent') {
if (isset($input['isHidden']) && $input['isHidden']) return null;
return $value;
}
} catch (Exception $e) {
// do nothing
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment