You are here

public static function YamlFormCreditCard::getCompositeElements in YAML Form 8

Same name in this branch
  1. 8 src/Element/YamlFormCreditCard.php \Drupal\yamlform\Element\YamlFormCreditCard::getCompositeElements()
  2. 8 src/Plugin/YamlFormElement/YamlFormCreditCard.php \Drupal\yamlform\Plugin\YamlFormElement\YamlFormCreditCard::getCompositeElements()

Get a renderable array of form elements.

Return value

array A renderable array of form elements, containing the base properties for the composite's form elements.

Overrides YamlFormCompositeBase::getCompositeElements

1 call to YamlFormCreditCard::getCompositeElements()
YamlFormCreditCard::getCompositeElements in src/Plugin/YamlFormElement/YamlFormCreditCard.php
Get composite elements.

File

src/Element/YamlFormCreditCard.php, line 15

Class

YamlFormCreditCard
Provides a form element for a credit card element.

Namespace

Drupal\yamlform\Element

Code

public static function getCompositeElements() {
  $month_options = range(1, 12);
  $year_options = range(date('Y'), date('Y') + 10);
  $elements = [];
  $elements['warning'] = [
    '#type' => 'yamlform_message',
    '#message_type' => 'warning',
    '#message_message' => t('The credit card element is experimental and insecure because it stores submitted information as plain text.'),
  ];
  $elements['name'] = [
    '#type' => 'textfield',
    '#title' => t("Name on Card"),
  ];
  $elements['type'] = [
    '#type' => 'select',
    '#title' => t('Type of Card'),
    '#options' => 'creditcard_codes',
  ];
  $elements['number'] = [
    '#type' => 'yamlform_creditcard_number',
    '#title' => t('Card Number'),
  ];
  $elements['civ'] = [
    '#type' => 'number',
    '#title' => t('CIV Number'),
    '#min' => 1,
    '#size' => 4,
    '#maxlength' => 4,
    '#test' => [
      111,
      222,
      333,
    ],
  ];
  $elements['expiration'] = [
    '#type' => 'label',
    '#title' => t('Expiration Date'),
  ];
  $elements['expiration_month'] = [
    '#title' => t('Expiration Month'),
    '#title_display' => 'invisible',
    '#type' => 'select',
    '#options' => array_combine($month_options, $month_options),
    '#prefix' => '<div class="container-inline clearfix">',
  ];
  $elements['expiration_year'] = [
    '#title' => t('Expiration Year'),
    '#title_display' => 'invisible',
    '#type' => 'select',
    '#options' => array_combine($year_options, $year_options),
    '#suffix' => '</div>',
  ];
  return $elements;
}