nliautaud / p01contact

Create contact forms by writing simple tags. Also a plugin for GetSimple and Pico CMS.
MIT License
16 stars 15 forks source link

Checkbox (Group of checkboxes) #52

Open gs58muse opened 4 years ago

gs58muse commented 4 years ago

Hi Nicolas,

I'm testing p01-contact V1.1.6 in Get Simpe V3.15. PHP 7.2.10
When a Checkbox has more than 1 Option = "checkbox "Checkbox-Test" = one | two | five " only the last Selected Checkbox Value will be sent via e-Mail

I think the Problem is in "P01contact_Field.php" Line 229 case 'checkbox': case 'radio':

case 'checkbox': can be in array

I changed it to: case 'checkbox': $html .= '<div class="options">'; foreach ($this->value as $i => $v) { $selected = $this->isSelected($i) ? ' checked' : ''; $v = !empty($v) ? $v : 'Default'; $html .= '<label class="option">'; $html .= "<input id=\"{$id}_option{$i}\""; $html .= " type=\"$type\" class=\"$type\" name=\"{$name}[$i]\""; $html .= " value=\"$i\"$disabled$required$selected />$v"; $html .= '</label>'; } $html .= '</div>'; break;

Radio is (as until now): case 'radio': $html .= '<div class="options">'; foreach ($this->value as $i => $v) { $selected = $this->isSelected($i) ? ' checked' : ''; $v = !empty($v) ? $v : 'Default'; $html .= '<label class="option">'; $html .= "<input id=\"{$id}_option{$i}\""; $html .= " type=\"$type\" class=\"$type\" name=\"{$name}\""; $html .= " value=\"$i\"$disabled$required$selected />$v"; $html .= '</label>'; } $html .= '</div>'; break;

This Fix works for me - but: If the Checkbox-Group is a required Form-Field every Checkbox in the Group must be checked to send the Form

Greetings Gerhard