跳转到主要内容
learningxm 提交于 29 November 2012

1、filedset更新为details

2、使用yml方式保存变量

<?php /** * Implements hook_form_FORM_ID_alter(). * * Add the default personal contact setting on the user settings page. * * @see user_admin_settings() */ function contact_form_user_admin_settings_alter(&$form, &$form_state) { $form['contact'] = array( '#type' => 'details', //--原来使用fieldset '#title' => t('Contact settings'), '#weight' => 0, ); $form['contact']['contact_default_status'] = array( '#type' => 'checkbox', '#title' => t('Enable the personal contact form by default for new users.'), '#description' => t('Changing this setting will not affect existing users.'), '#default_value' => config('contact.settings')->get('user_default_enabled'), ); // Add submit handler to save contact configuration. $form['#submit'][] = 'contact_form_user_admin_settings_submit'; } /** * Form submission handler for user_admin_settings(). * * @see contact_form_user_admin_settings_alter() */ //--新的保存变量的方法 function contact_form_user_admin_settings_submit($form, &$form_state) { config('contact.settings') ->set('user_default_enabled', $form_state['values']['contact_default_status']) ->save(); } ?>