function block_machine_name_submit in Block Machine Name 7
Save machine name.
1 string reference to 'block_machine_name_submit'
- block_machine_name_form_alter in ./
block_machine_name.module - Implements hook_form_alter(). @todo - Alter various block forms to add our field elements or submit/validate handlers
File
- ./
block_machine_name.module, line 137
Code
function block_machine_name_submit($form, &$form_state) {
// If the user didn't supply a value, don't do anything
if (empty($form_state['values']['machine_name'])) {
return;
}
// Build a record to insert
$delta = $form_state['values']['delta'];
$module = $form_state['values']['module'];
$machine_name = $form_state['values']['machine_name'];
$record = array(
// Block delta
'delta' => $delta,
// The user supplied machine name
'machine_name' => $machine_name,
// The module controlling this block - module + delta yield a unique identifier for this block
'module' => $module,
);
// Clear out any existing entry for this block and then insert the new record
$table = 'block_machine_name_boxes';
db_delete($table)
->condition('delta', $delta)
->condition('module', $module)
->execute();
drupal_write_record($table, $record);
}