52 $config = array_merge( [
55 'longDisplayFormat' =>
false,
59 if ( isset( $config[
'inputFormat'] ) ) {
60 $this->inputFormat = $config[
'inputFormat'];
62 if ( isset( $config[
'placeholderDateFormat'] ) ) {
63 $this->placeholderDateFormat = $config[
'placeholderDateFormat'];
65 $this->precision = $config[
'precision'];
66 if ( isset( $config[
'mustBeAfter'] ) ) {
67 $this->mustBeAfter = $config[
'mustBeAfter'];
69 if ( isset( $config[
'mustBeBefore'] ) ) {
70 $this->mustBeBefore = $config[
'mustBeBefore'];
74 if ( isset( $config[
'displayFormat'] ) ) {
75 $this->displayFormat = $config[
'displayFormat'];
77 if ( isset( $config[
'longDisplayFormat'] ) ) {
78 $this->longDisplayFormat = $config[
'longDisplayFormat'];
80 if ( isset( $config[
'placeholderLabel'] ) ) {
81 $this->placeholderLabel = $config[
'placeholderLabel'];
85 if ( $this->placeholderDateFormat !==
null ) {
87 } elseif ( $this->inputFormat !==
null ) {
91 $placeholder =
wfMessage(
"mw-widgets-dateinput-placeholder-$this->precision" )->text();
94 $config = array_merge( [
96 'placeholder' => $placeholder,
99 parent::__construct( $config );
103 if ( $this->mustBeAfter !==
null ) {
104 $min =
new DateTime( $this->mustBeAfter );
105 $min = $min->modify(
'+1 day' );
106 $min = $min->format(
'Y-m-d' );
107 $this->input->setAttributes( [
'min' => $min ] );
109 if ( $this->mustBeBefore !==
null ) {
110 $max =
new DateTime( $this->mustBeBefore );
111 $max = $max->modify(
'-1 day' );
112 $max = $max->format(
'Y-m-d' );
113 $this->input->setAttributes( [
'max' => $max ] );
117 $this->addClasses( [
'mw-widget-dateInputWidget' ] );