Fix clearing multiple-value fields does not process input
Multi-value CiviMRF Reference fields will not process their input when they are being cleared. This can be reproduced when e.g. using multiple Webform wizard pages. When advancing to the next wizard page with a reference field having a value, it will be saved. When going back to that wizard page and clearing the value, then advancing to the next page, the previous value remains, as the "clearing" of the value will cause a NULL
input value and thus no input processing for that field, keeping the previous value in form state values.
This MR makes the value callback return an empty array for multi-value reference fields when the input is NULL
(caused by browsers not including empty select
elements in the request/post array at all).
The Drupal Core Select
type field would do that in its value callback, but the reference field is being derived from Textfield
, regardless of whether it is multi-value or not. So the value callback for CiviMRF Reference fields is now a mixture of the one for the Select
element when it's multi-value, and the Textfield
element when it's single-value.