function answers_lock_example_form_alter in Answers 7.4
Implements hook_form_alter().
Update the answers system settings form to contain an additional setting.
File
- answers_lock_example/
answers_lock_example.module, line 43 - Example module of the question 'lock'.
Code
function answers_lock_example_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
// Update the administrative settings form to have settings for AGL.
case 'answers_settings':
$form['answers_lock_example_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Answers Lock Example Settings',
'#description' => 'Demonstrate the question locking functionality',
'#weight' => 10,
);
$old = variable_get('answers_lock_example_lock_questions_p', 0);
$form['answers_lock_example_settings']['answers_lock_example_lock_questions_p'] = array(
'#type' => 'checkbox',
'#title' => 'Lock all questions?',
'#description' => 'If set, all questions will be locked. If unset, all questions will be unlocked (unless they are locked for another reason)',
'#default_value' => $old,
);
// Store the old value.
$form['answers_lock_example_settings']['answers_lock_example_old_lock_questions_p'] = array(
'#type' => 'value',
'#value' => $old,
);
// Add in a submit handler *before* the standard handler.
$form['#submit'][] = 'answers_lock_example_settings_form_submit';
break;
}
}