Closed patdunlavey closed 8 years ago
Tagging @DiegoPino
Question: Should we always remove/nullify cloned multi-value (tab, tag) child elements in this function, or should there be an argument to the function "reset_clone" that can be set to TRUE or FALSE? If so, should "reset_clone" = TRUE be the default? Perhaps let this be indicated somehow in the $mode argument?
As commented in this pull request: https://github.com/commonmedia/islandora_webform/pull/28/files#r49488474, We only are trying to clone the structure of the descendent special xmlform elements, not their data. So there is no reason to keep more than one.
We can close this issue when that pull request is accepted.
When iwi_set_form_element_byhash clones a tab, it copies all the children of that tab, including tags and even tabsets which themselves are multi-value fields. The purpose of this cloning is to give us a copy of the form element's complete schema, and none of its data.
Currently, iwi_set_form_element_byhash sets the values of all descendants of the cloned element to NULL. However, when one of the children is a multi-value field, it leaves those multiple instances in place, setting all their values to NULL. Instead, it should remove all but one of them. In this way, we preserve the form element schema without carrying over a "ghost" of NULL values reflecting all the data that existed in the original.