PersianDate.php in Persian Date for Drupal 8 8
File
src/Element/PersianDate.php
View source
<?php
namespace Drupal\persian_date\Element;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Annotation\FormElement;
use Drupal\Core\Render\Element\Date;
class PersianDate extends Date {
public function getInfo() {
$info = parent::getInfo();
$info['#attributes'] = [
'type' => 'text',
];
return $info;
}
public static function processDate(&$element, FormStateInterface $form_state, &$complete_form) {
if ($element['#attributes']['type'] == 'date' && !empty($element['#date_date_format'])) {
$element['#attributes']['type'] = 'text';
$element['#attached']['library'][] = 'persian_date/core';
$element['#attributes']['data-drupal-date-format'] = [
$element['#date_date_format'],
];
}
return $element;
}
}
Classes
Name |
Description |
PersianDate |
Class PersianDate
@package Drupal\persian_date\Element |