MediaWiki master
HTMLFormFieldWithButton.php
Go to the documentation of this file.
1<?php
2
4
7
17 protected $mButtonClass = '';
18
20 protected $mButtonId = '';
21
23 protected $mButtonName = '';
24
26 protected $mButtonType = 'submit';
27
29 protected $mButtonValue;
30
32 protected $mButtonFlags = [ 'progressive' ];
33
38 public function __construct( $info ) {
39 if ( isset( $info['buttonclass'] ) ) {
40 $this->mButtonClass = $info['buttonclass'];
41 }
42 if ( isset( $info['buttonid'] ) ) {
43 $this->mButtonId = $info['buttonid'];
44 }
45 if ( isset( $info['buttonname'] ) ) {
46 $this->mButtonName = $info['buttonname'];
47 }
48 if ( isset( $info['buttondefault'] ) ) {
49 $this->mButtonValue = $info['buttondefault'];
50 }
51 if ( isset( $info['buttontype'] ) ) {
52 $this->mButtonType = $info['buttontype'];
53 }
54 if ( isset( $info['buttonflags'] ) ) {
55 $this->mButtonFlags = $info['buttonflags'];
56 }
57 parent::__construct( $info );
58 }
59
61 public function getInputHTML( $value ) {
62 $attr = [
63 'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
64 'id' => $this->mButtonId,
65 ] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
66
67 return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
68 }
69
71 public function getInputOOUI( $value ) {
72 return new \OOUI\ButtonInputWidget( [
73 'name' => $this->mButtonName,
74 'value' => $this->mButtonValue,
75 'type' => $this->mButtonType,
76 'label' => $this->mButtonValue,
77 'flags' => $this->mButtonFlags,
78 'id' => $this->mButtonId ?: null,
79 ] + \OOUI\Element::configFromHtmlAttributes(
80 $this->getAttributes( [ 'disabled', 'tabindex' ] )
81 ) );
82 }
83
89 public function getElement( $element ) {
90 return $element . "\u{00A0}" . $this->getInputHTML( '' );
91 }
92}
93
95class_alias( HTMLFormFieldWithButton::class, 'HTMLFormFieldWithButton' );
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 $mButtonClass
CSS class for the button in this field.
string[] $mButtonFlags
Value for the button in this field.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
string $mButtonValue
Value for the button in this field.
getElement( $element)
Combines the passed element with a button.
string $mButtonType
Type of the button in this field (e.g.
string int $mButtonId
Element ID for the button in this field.
The parent class to generate form fields.
getAttributes(array $list)
Returns the given attributes from the parameters.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43