18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5<br />

'#default_value' => variable_get('user_warn_e-mail_subject',<br />

'Administrative Warning'),<br />

'#title' => t('Warning e-mail subject'),<br />

'#size' => 40,<br />

'#maxlength' => 120,<br />

'#required' => TRUE,<br />

'#description' => t(<br />

'The subject of the e-mail which will be sent to users.'),<br />

);<br />

// Textarea for the body of the e-mail.<br />

$form['user_warn_e-mail_text'] = array(<br />

'#type' => 'textarea',<br />

'#rows' => 10,<br />

'#columns' => 40,<br />

'#default_value' => variable_get('user_warn_e-mail_text',<br />

USER_WARN_MAIL_TEXT),<br />

'#title' => t('Warning e-mail text'),<br />

'#required' => TRUE,<br />

'#description' => t(<br />

'The text of the e-mail which will be sent to users. '),<br />

);<br />

// Checkbox to indicate whether admin should be sent a Bcc<br />

// on e-mails.<br />

$form['user_warn_bcc'] = array(<br />

'#type' => 'checkbox',<br />

'#default_value' => variable_get('user_warn_bcc', FALSE),<br />

'#title' => t('BCC admin on all e-mails'),<br />

'#description' => t('Indicates whether the admin user (as set in<br />

site configuration) should be BCC\'d on all warning e-mails.'),<br />

);<br />

// Submit button<br />

$form['submit'] = array(<br />

'#type' => 'submit',<br />

'#value' => t('Save settings'),<br />

);<br />

}<br />

return $form;<br />

Persistent variables are an excellent way to store module settings and other<br />

user-configurable information. However, having given our configuration settings<br />

reasonable defaults, we are still left with the issue of how to save changes to<br />

these defaults.<br />

[ 135 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!