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.
19 public function __construct( array $params = [] ) {
20 parent
::__construct( $params );
22 $type = !empty( $params['options'] ) ?
'selectorother' : 'text';
23 $this->relativeField
= $this->getFieldByType( $type );
29 * Use whatever the relative field is as the standard HTML input.
31 public function getInputHTML( $value ) {
32 return $this->relativeField
->getInputHTML( $value );
35 protected function shouldInfuseOOUI() {
42 protected function getOOUIModules() {
45 'mediawiki.widgets.expiry',
47 $this->relativeField
->getOOUIModules()
54 public function getInputOOUI( $value ) {
55 return new ExpiryInputWidget(
56 $this->relativeField
->getInputOOUI( $value ),
59 'required' => $this->mParams
['required'] ??
false,
67 public function loadDataFromRequest( $request ) {
68 return $this->relativeField
->loadDataFromRequest( $request );
72 * Get the HTMLForm field by the type string.
75 * @return \HTMLFormField
77 protected function getFieldByType( $type ) {
78 $class = HTMLForm
::$typeMappings[$type];
79 $params = $this->mParams
;
80 $params['type'] = $type;
81 $params['class'] = $class;
83 // Remove Parameters that are being used on the parent.
84 unset( $params['label-message'] );
85 return new $class( $params );