Skip to content
Snippets Groups Projects
Commit dac85c3a authored by Melissa Miller's avatar Melissa Miller
Browse files

Initial commit; start of module

parents
No related branches found
No related tags found
No related merge requests found
{
"name": "ocio_odee_web/wcm8_siteinfo",
"description": "Adds additional site configuration fields such as contact info and social media links.",
"type": "drupal-module",
"license": "None",
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.5"
}
}
<?php
namespace Drupal\wcm8_siteinfo\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Defines a form that configures module settings.
*/
class ModuleConfigurationForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'wcm8_siteinfo_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'wcm8_siteinfo.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('wcm8_siteinfo.settings');
$form['siteinfo'] = array(
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-basic',
);
// Basic Information tab
$form['basic'] = array(
'#type' => 'details',
'#title' => $this->t('Basic Information'),
'#group' => 'siteinfo',
);
$form['basic']['prefix'] = array(
'#type' => 'textfield',
'#title' => $this->t('Site Name Prefix'),
'#description' => $this->t('The prefix for your site name - for example, <i>Department of</i> ... '),
'#size' => '60',
'#maxlength' => '60',
'#default_value' => $config->get('prefix'),
);
$form['basic']['site_name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Site Name'),
'#description' => $this->t('Main name for the site - it should be your college, department or organization name.'),
'#size' => '60',
'#maxlength' => '75',
'#default_value' => $this->config('system.site')->get('name'),
);
// Contact Information tab
$form['contact'] = array(
'#type' => 'details',
'#title' => $this->t('Contact Information'),
'#group' => 'siteinfo',
);
$form['contact']['address_1'] = array(
'#type' => 'textfield',
'#title' => $this->t('Address Line 1'),
'#description' => $this->t('First line of address. Room number and building if on campus.'),
'#default_value' => $config->get('address_1'),
);
$form['contact']['address_2'] = array(
'#type' => 'textfield',
'#title' => $this->t('Address Line 2'),
'#description' => $this->t('Second line of address. Street address if on campus.'),
'#default_value' => $config->get('address_2'),
);
$form['contact']['city'] = array(
'#type' => 'textfield',
'#title' => $this->t('City'),
'#default_value' => $config->get('city'),
);
$form['contact']['state'] = array(
'#type' => 'textfield',
'#title' => $this->t('State'),
'#default_value' => $config->get('state'),
);
$form['contact']['zip'] = array(
'#type' => 'textfield',
'#title' => $this->t('Zip Code'),
'#default_value' => $config->get('zip'),
);
$form['contact']['phone'] = array(
'#type' => 'tel',
'#title' => $this->t('Phone'),
'#description' => $this->t('Main contact phone number for your site.'),
'#default_value' => $config->get('phone'),
);
$form['contact']['fax'] = array(
'#type' => 'tel',
'#title' => $this->t('Fax'),
'#description' => $this->t('Fax number, if applicable.'),
'#default_value' => $config->get('fax'),
);
$form['contact']['email'] = array(
'#type' => 'email',
'#title' => $this->t('Email'),
'#description' => $this->t('Main contact email for your site.'),
'#default_value' => $config->get('email'),
);
// Social Networking tab
$form['social'] = array(
'#type' => 'details',
'#title' => $this->t('Social Networking'),
'#group' => 'siteinfo',
);
$form['social']['twitter'] = array(
'#type' => 'textfield',
'#title' => $this->t('Twitter'),
'#default_value' => $config->get('twitter'),
);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
$this->config('wcm8_siteinfo.settings')
->set('prefix', $values['prefix'])
->set('address_1', $values['address_1'])
->set('address_2', $values['address_2'])
->set('city', $values['city'])
->set('state', $values['state'])
->set('zip', $values['zip'])
->set('phone', $values['phone'])
->set('fax', $values['fax'])
->set('email', $values['email'])
->set('twitter', $values['twitter'])
->save();
parent::submitForm($form, $form_state);
}
}
\ No newline at end of file
name: Site Information
description: Adds additional site configuration fields such as contact info and social media links.
package: WCM8
type: module
core: 8.x
configure: wcm8_siteinfo.admin_settings
\ No newline at end of file
wcm8_siteinfo.settings:
title: 'Site Information'
description: 'Additional site settings provided by the Site Information module.'
parent: system.admin_config_system
route_name: wcm8_siteinfo.admin_settings
weight: 1
\ No newline at end of file
administer wcm8_siteinfo configuration:
title: 'Administer Site Information'
description: 'Access and edit Site Information fields.'
\ No newline at end of file
wcm8_siteinfo.admin_settings:
path: 'admin/config/system/siteinfo'
defaults:
_form: '\Drupal\wcm8_siteinfo\Form\ModuleConfigurationForm'
_title: 'Site Information'
requirements:
_permission: 'Administer Site Information'
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment