MediaWiki  1.34.0
HTMLFormFieldWithButton.php
Go to the documentation of this file.
1 <?php
7  protected $mButtonClass = '';
8 
10  protected $mButtonId = '';
11 
13  protected $mButtonName = '';
14 
16  protected $mButtonType = 'submit';
17 
19  protected $mButtonValue;
20 
22  protected $mButtonFlags = [ 'progressive' ];
23 
24  public function __construct( $info ) {
25  if ( isset( $info['buttonclass'] ) ) {
26  $this->mButtonClass = $info['buttonclass'];
27  }
28  if ( isset( $info['buttonid'] ) ) {
29  $this->mButtonId = $info['buttonid'];
30  }
31  if ( isset( $info['buttonname'] ) ) {
32  $this->mButtonName = $info['buttonname'];
33  }
34  if ( isset( $info['buttondefault'] ) ) {
35  $this->mButtonValue = $info['buttondefault'];
36  }
37  if ( isset( $info['buttontype'] ) ) {
38  $this->mButtonType = $info['buttontype'];
39  }
40  if ( isset( $info['buttonflags'] ) ) {
41  $this->mButtonFlags = $info['buttonflags'];
42  }
43  parent::__construct( $info );
44  }
45 
46  public function getInputHTML( $value ) {
47  $attr = [
48  'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
49  'id' => $this->mButtonId,
50  ] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
51 
52  return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
53  }
54 
55  public function getInputOOUI( $value ) {
56  return new OOUI\ButtonInputWidget( [
57  'name' => $this->mButtonName,
58  'value' => $this->mButtonValue,
59  'type' => $this->mButtonType,
60  'label' => $this->mButtonValue,
61  'flags' => $this->mButtonFlags,
62  'id' => $this->mButtonId ?: null,
63  ] + OOUI\Element::configFromHtmlAttributes(
64  $this->getAttributes( [ 'disabled', 'tabindex' ] )
65  ) );
66  }
67 
73  public function getElement( $element ) {
74  return $element . "\u{00A0}" . $this->getInputHTML( '' );
75  }
76 }
HTMLFormFieldWithButton\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
Definition: HTMLFormFieldWithButton.php:55
HTMLFormFieldWithButton\$mButtonFlags
string[] $mButtonFlags
$mButtonType Value for the button in this field
Definition: HTMLFormFieldWithButton.php:22
HTMLFormFieldWithButton\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLFormFieldWithButton.php:46
HTMLFormFieldWithButton\__construct
__construct( $info)
Initialise the object.
Definition: HTMLFormFieldWithButton.php:24
HTMLFormFieldWithButton\getElement
getElement( $element)
Combines the passed element with a button.
Definition: HTMLFormFieldWithButton.php:73
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
HTMLFormFieldWithButton
Enables HTMLFormField elements to be build with a button.
Definition: HTMLFormFieldWithButton.php:5
HTMLFormFieldWithButton\$mButtonClass
$mButtonClass
Definition: HTMLFormFieldWithButton.php:7
HTMLFormFieldWithButton\$mButtonType
$mButtonType
Definition: HTMLFormFieldWithButton.php:16
HTMLFormFieldWithButton\$mButtonValue
string $mButtonValue
$mButtonType Value for the button in this field
Definition: HTMLFormFieldWithButton.php:19
HTMLFormFieldWithButton\$mButtonId
$mButtonId
Definition: HTMLFormFieldWithButton.php:10
HTMLFormFieldWithButton\$mButtonName
$mButtonName
Definition: HTMLFormFieldWithButton.php:13
HTMLFormField\getAttributes
getAttributes(array $list)
Returns the given attributes from the parameters.
Definition: HTMLFormField.php:998