Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I would like to add a checkbox of my own to the performance page in the Drupal administration. I am using hook_form_alter like this:

function nci_assay_depot_form_alter(&$form, &$form_state, $form_id){
    switch($form_id){
        case "system_performance_settings":
            $form["caching"]["nci_assay_depot"] = array(
                "#type" => "checkbox"
                ,"#title" => "Refresh Assay Depot Cache when 'Clear All Caches'"
                ,"#default_value" => 1
                ,"#disabled" => 0
                ,"#description" => null
                ,"#weight" => -2
            ) ;
        break;
    }
}

It will display on the page, but the value will not be saved. Any thoughts?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted
  • to have it "repopulate" after save provide a #default_value key that retrieves it on page load.
  • to actually save it append (add another) custom form submit handler to the form, after the original one gets fired. Something like $form['#submit'][] = 'mymodule_mysubmit_handler'; You will have to check where the submit handler is set already in the form, or the element you're trying to hook into (such as $form['caching'] ...
share|improve this answer
    
This worked perfectly, thank you! –  Nate Starner Jan 28 '13 at 17:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.