You are here

function disable_field_disable_validate in Disable Field 7

Same name and namespace in other branches
  1. 8 disable_field.module \disable_field_disable_validate()

Implements hook_form_validate().

1 string reference to 'disable_field_disable_validate'
disable_field_form_alter in ./disable_field.module
Implements hook_form_alter().

File

./disable_field.module, line 129
Defines a checkbox field to disable by admin in Field Edit page.

Code

function disable_field_disable_validate($form, &$form_state) {

  // Checking User Access.
  if (user_access("disable textfield module")) {
    $add_disable = $form_state['values']['field']['add_disable']['add_disable'];
    $edit_disable = $form_state['values']['field']['edit_disable']['edit_disable'];
    $roles_add = $form_state['values']['field']['roles_add'];
    $roles_edit = $form_state['values']['field']['roles_edit'];

    // For add checkbox;
    if (strlen($add_disable) == 11) {
      if (empty($roles_add)) {
        form_set_error("roles_add", t('Select Atleast one Role to disable add.'));
      }
    }

    // For Edit checkbox.
    if (strlen($edit_disable) == 12) {
      if (empty($roles_edit)) {
        form_set_error("roles_edit", t('Select Atleast one Role to disable edit.'));
      }
    }
  }
}