You are here

function readonlymode_readonly_form in Read only mode 7

After build callback to render read only forms.

File

./readonlymode.module, line 112
The Read Ony Mode main module file.

Code

function readonlymode_readonly_form($element) {
  if (isset($element['#type'])) {
    if (in_array($element['#type'], array(
      'button',
      'image_button',
      'submit',
    ))) {
      $element['#access'] = FALSE;
    }
    else {
      $element['#attributes']['readonly'] = 'readonly';
      $element['#attributes']['disabled'] = 'disabled';
    }
  }

  // Recurse for any child elements.
  foreach (element_children($element) as $key) {
    $element[$key] = readonlymode_readonly_form($element[$key]);
  }
  return $element;
}