Skip to content

Instantly share code, notes, and snippets.

@mattfarina
Created May 20, 2010 21:22
Show Gist options
  • Save mattfarina/408130 to your computer and use it in GitHub Desktop.
Save mattfarina/408130 to your computer and use it in GitHub Desktop.
/**
* Helper function; removes all required element flags on a section of a form.
*
* @param array $element
* A form or section of a form.
*
* @return array
* A section of a form tree with #required = 0 everyehere.
*/
function example_remove_required($element) {
if (isset($element['#required']) && $element['#required'] == 1) {
$element['#required'] = 0;
}
$children = element_children($element);
foreach ($children as $key) {
$element[$key] = icalfield_ajaxy_remove_required($element[$key]);
}
return $element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment