You are here

interval.module in Interval Field 8

Same filename and directory in other branches
  1. 7 interval.module

Defines an interval field. @copyright Copyright(c) 2011 Rowlands Group @license GPL v2+ http://www.fsf.org/licensing/licenses/gpl.html @author Lee Rowlands leerowlands at rowlandsgroup dot com

File

interval.module
View source
<?php

/**
 * @file
 * Defines an interval field.
 * @copyright Copyright(c) 2011 Rowlands Group
 * @license GPL v2+ http://www.fsf.org/licensing/licenses/gpl.html
 * @author Lee Rowlands leerowlands at rowlandsgroup dot com
 */

/**
 * Implements hook_theme().
 */
function interval_theme() {
  $hooks = [
    'interval' => [
      'render element' => 'element',
      'template' => 'interval',
    ],
  ];
  return $hooks;
}

/**
 * Returns HTML for an interval form element.
 */
function template_preprocess_interval(&$variables) {
  $element = $variables['element'];
  $variables['attributes'] = [];
  if (isset($element['#id'])) {
    $variables['attributes']['id'] = $element['#id'];
  }
  if (!empty($element['#attributes']['class'])) {
    $variables['attributes']['class'] = (array) $element['#attributes']['class'];
  }
  $variables['attributes']['class'][] = 'container-inline';
  $variables['children'] = \Drupal::service('renderer')
    ->render($element);
}

Functions

Namesort descending Description
interval_theme Implements hook_theme().
template_preprocess_interval Returns HTML for an interval form element.