MediaWiki REL1_35
HTMLFormFieldWithButton.php
Go to the documentation of this file.
1<?php
9 protected $mButtonClass = '';
10
12 protected $mButtonId = '';
13
15 protected $mButtonName = '';
16
18 protected $mButtonType = 'submit';
19
21 protected $mButtonValue;
22
24 protected $mButtonFlags = [ 'progressive' ];
25
26 /*
27 * @stable to call
28 */
29 public function __construct( $info ) {
30 if ( isset( $info['buttonclass'] ) ) {
31 $this->mButtonClass = $info['buttonclass'];
32 }
33 if ( isset( $info['buttonid'] ) ) {
34 $this->mButtonId = $info['buttonid'];
35 }
36 if ( isset( $info['buttonname'] ) ) {
37 $this->mButtonName = $info['buttonname'];
38 }
39 if ( isset( $info['buttondefault'] ) ) {
40 $this->mButtonValue = $info['buttondefault'];
41 }
42 if ( isset( $info['buttontype'] ) ) {
43 $this->mButtonType = $info['buttontype'];
44 }
45 if ( isset( $info['buttonflags'] ) ) {
46 $this->mButtonFlags = $info['buttonflags'];
47 }
48 parent::__construct( $info );
49 }
50
51 public function getInputHTML( $value ) {
52 $attr = [
53 'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
54 'id' => $this->mButtonId,
55 ] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
56
57 return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
58 }
59
60 public function getInputOOUI( $value ) {
61 return new OOUI\ButtonInputWidget( [
62 'name' => $this->mButtonName,
63 'value' => $this->mButtonValue,
64 'type' => $this->mButtonType,
65 'label' => $this->mButtonValue,
66 'flags' => $this->mButtonFlags,
67 'id' => $this->mButtonId ?: null,
68 ] + OOUI\Element::configFromHtmlAttributes(
69 $this->getAttributes( [ 'disabled', 'tabindex' ] )
70 ) );
71 }
72
78 public function getElement( $element ) {
79 return $element . "\u{00A0}" . $this->getInputHTML( '' );
80 }
81}
Enables HTMLFormField elements to be build with a button.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
string int $mButtonId
Element ID for the button in this field.
getElement( $element)
Combines the passed element with a button.
string $mButtonClass
CSS class for the button in this field.
string $mButtonValue
Value for the button in this field.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
string $mButtonName
Name the button in this field.
__construct( $info)
Initialise the object.
string[] $mButtonFlags
Value for the button in this field.
string $mButtonType
Type of the button in this field (e.g.
The parent class to generate form fields.
getAttributes(array $list)
Returns the given attributes from the parameters Stable to override.