php - Could someone assist me with that save form? -
here follows admin.inc file user's form.in example have return system_settings_form($pppp_form);
want make on own save button , save values when user press save.... form code bellow doing same thing , works want own save-form because form not save values want checkboxes me make own form?? need help!! thank much..!
/** * settings form user. */ function pppp_admin_settings() { $pppp_form['pppp_key'] = array( '#type' => 'textfield', '#title' => t('pppp'), '#default_value' => variable_get('pppp_key', ''), '#description' => t('pppp.'), '#required' => true, '#size' => 28, '#required' => true, ); $pppp_options = array( '0' => 'no values', '100' => '100', '500' => '500', '1000' => '1000', '5000' => '5000', '50000' => '50000', '1000000' => '1000000' ); $pppp_form['pppp_number_select'] = array( '#type' => 'select', '#options' => $pppp_options, '#description' => t('select how many values want check.'), '#default_value' => variable_get('pppp_number_select', '0'), ); $pppp_severity_levels = variable_get('pppp_severity_levels', array()); $pppp_severity_options = array(); foreach (watchdog_severity_levels() $pppp_severity_number => $pppp_severity) { $pppp_options[$pppp_severity_number] = check_plain(drupal_ucfirst( $pppp_severity)); } $pppp_form['pppp_severity'] = array( '#type' => 'fieldset', '#title' => t('pppp.'), '#collapsible' => true, '#collapsed' => true, ); $pppp_form['pppp_severity']['pppp_severity_levels'] = array( '#type' => 'checkboxes', '#title' => t('type of log messages'), '#options' => $pppp_severity_options, '#default_value' => array_values($pppp_severity_levels), '#required' => true, ); return system_settings_form($pppp_form); }
the system_settings_form($form) function shortcut allows build form without having worry save button/submit handler (those added automatically).
if want build full form including submit handler etc you'll have define form function , form submit handler , call via drupal_get_form('my_form_name_admin_settings_form');
define form function
this can have name want
my_form_name_admin_settings_form($form, &$form_state){ //put form array here- //add submit button $form['submit'] = array( '#type' => 'submit', '#value' => 'save' ); return $form; }
define submit handler
after form submitted automattically try call my_form_name_admin_settings_form_submit we'll have define submit handler
my_form_name_admin_settings_form_submit($form, &$form_state){ //all input in $form_state['input'] we'll put in message see what's happening. drupal_set_message('<pre>' . print_r($form_state['input'], true) . '</pre>'); //do thing data //save via variable set }
print form
call form via drupal_get_form need it.
drupal_get_form('my_form_name_admin_settings_form');
Comments
Post a Comment