function disable_field_disable_submit in Disable Field 7
Implements submit function.
1 string reference to 'disable_field_disable_submit'
- disable_field_form_alter in ./
disable_field.module - Implements hook_form_alter().
File
- ./
disable_field.module, line 154 - Defines a checkbox field to disable by admin in Field Edit page.
Code
function disable_field_disable_submit($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'];
$field_name = $form_state['values']['instance']['field_name'];
$bundle_type = $form_state['values']['instance']['bundle'];
$entity_type = $form_state['values']['instance']['entity_type'];
$roles_add = $form_state['values']['field']['roles_add'];
$roles_edit = $form_state['values']['field']['roles_edit'];
if (!empty($roles_add)) {
$roles_add = array_keys($roles_add);
}
if (!empty($roles_edit)) {
$roles_edit = array_keys($roles_edit);
}
// Unchecked box.
if (strlen($add_disable) == 1) {
db_delete('disable_field')
->condition('entity_type', $entity_type)
->condition('bundle', $bundle_type)
->condition('field_name', $field_name)
->condition('disable_page', 'add_disable')
->execute();
}
if (strlen($edit_disable) == 1) {
db_delete('disable_field')
->condition('entity_type', $entity_type)
->condition('bundle', $bundle_type)
->condition('field_name', $field_name)
->condition('disable_page', 'edit_disable')
->execute();
}
// For add checkbox;
if (strlen($add_disable) == 11) {
db_merge('disable_field')
->key(array(
'entity_type' => $entity_type,
'bundle' => $bundle_type,
'field_name' => $field_name,
'page' => 'add',
'disable_page' => 'add_disable',
))
->fields(array(
'status' => 1,
'roles' => json_encode($roles_add),
))
->execute();
}
// For Edit checkbox.
if (strlen($edit_disable) == 12) {
db_merge('disable_field')
->key(array(
'entity_type' => $entity_type,
'bundle' => $bundle_type,
'field_name' => $field_name,
'page' => 'edit',
'disable_page' => 'edit_disable',
))
->fields(array(
'status' => 1,
'roles' => json_encode($roles_edit),
))
->execute();
}
}
}