Last active
December 13, 2015 17:58
-
-
Save thelebster/4951475 to your computer and use it in GitHub Desktop.
Disable selected form fields by name. #drupal #form #helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable selected form fields by name. | |
* | |
* @param array $fields | |
* Array of fields names that needs to be disabled. | |
*/ | |
function MYMODULE_form_helper_disable_fields(&$form, $fields = array()) { | |
if (is_array($fields)) { | |
foreach ($fields as $field) { | |
if (isset($form[$field])) $form[$field]['#disabled'] = TRUE; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment