3 use MediaWiki\Widget\ExpiryInputWidget
;
6 * Expiry Field that allows the user to specify a precise date or a
7 * relative date string.
9 class HTMLExpiryField
extends HTMLFormField
{
14 protected $relativeField;
17 * Relative Date Time Field.
18 * @param array $params
20 public function __construct( array $params = [] ) {
21 parent
::__construct( $params );
23 $type = !empty( $params['options'] ) ?
'selectorother' : 'text';
24 $this->relativeField
= $this->getFieldByType( $type );
30 * Use whatever the relative field is as the standard HTML input.
32 public function getInputHTML( $value ) {
33 return $this->relativeField
->getInputHTML( $value );
36 protected function shouldInfuseOOUI() {
43 protected function getOOUIModules() {
46 'mediawiki.widgets.expiry',
48 $this->relativeField
->getOOUIModules()
55 public function getInputOOUI( $value ) {
56 return new ExpiryInputWidget(
57 $this->relativeField
->getInputOOUI( $value ),
60 'required' => $this->mParams
['required'] ??
false,
68 public function loadDataFromRequest( $request ) {
69 return $this->relativeField
->loadDataFromRequest( $request );
73 * Get the HTMLForm field by the type string.
76 * @return \HTMLFormField
78 protected function getFieldByType( $type ) {
79 $class = HTMLForm
::$typeMappings[$type];
80 $params = $this->mParams
;
81 $params['type'] = $type;
82 $params['class'] = $class;
84 // Remove Parameters that are being used on the parent.
85 unset( $params['label-message'] );
86 return new $class( $params );