You are here

public function CpfCnpjBase::getInfo in Brazilian IDs 8

Returns the element properties for this element.

Return value

array An array of element properties. See \Drupal\Core\Render\ElementInfoManagerInterface::getInfo() for documentation of the standard properties of all elements, and the return value format.

Overrides Textfield::getInfo

3 calls to CpfCnpjBase::getInfo()
CnpjElement::getInfo in src/Element/CnpjElement.php
Returns the element properties for this element.
CpfCnpjElement::getInfo in src/Element/CpfCnpjElement.php
Returns the element properties for this element.
CpfElement::getInfo in src/Element/CpfElement.php
Returns the element properties for this element.
3 methods override CpfCnpjBase::getInfo()
CnpjElement::getInfo in src/Element/CnpjElement.php
Returns the element properties for this element.
CpfCnpjElement::getInfo in src/Element/CpfCnpjElement.php
Returns the element properties for this element.
CpfElement::getInfo in src/Element/CpfElement.php
Returns the element properties for this element.

File

src/Element/CpfCnpjBase.php, line 41

Class

CpfCnpjBase
Base class for CPF and CNPJ elements.

Namespace

Drupal\brazilian_ids\Element

Code

public function getInfo() {
  $info = parent::getInfo();

  // Changes default input size.
  $info['#size'] = 20;

  // Adds validation callback.
  $info['#element_validate'] = [
    [
      get_class($this),
      'validateElement',
    ],
  ];

  // Adds mask properties to take effect when the Mask Field module (mask)
  // is enabled.
  $mask = $this
    ->getMaskDefaults();
  if ($mask && $this->moduleHandler
    ->moduleExists('mask')) {
    $helper = new \Drupal\mask\Helper\ElementHelper();
    $helper
      ->elementInfoAlter($info, $mask);
  }
  return $info;
}