Last active
August 29, 2015 13:57
-
-
Save LarsEliasNielsen/9367734 to your computer and use it in GitHub Desktop.
Drupal 7 Module Development: Config form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form(). | |
* | |
* Creates a configuration form. See the API reference for info on different | |
* form inputs. | |
* | |
* From API Reference: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7 | |
* | |
* @url: https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_form/7 | |
*/ | |
function espn_news_form($form, &$form_state) { | |
// Fieldset. | |
$form['espn_api'] = array( | |
'#type' => 'fieldset', | |
'#title' => t('ESPN API'), | |
'#weight' => 0, | |
'#collapsible' => TRUE, | |
'#collapsed' => FALSE, | |
); | |
// Textfield for API key. | |
$form['espn_api']['espn_news_api_key'] = array( | |
'#type' => 'textfield', | |
'#title' => t('ESPN API key'), | |
'#default_value' => variable_get('espn_news_api_key'), | |
'#size' => 40, | |
'#maxlength' => 24, | |
'#description' => t('API from ESPN Developer Center (http://developer.espn.com/apps/mykeys).'), | |
'#required' => TRUE, | |
); | |
return system_settings_form($form); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment