MediaWiki REL1_37
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
30 public function __construct( $info ) {
31 if ( isset( $info['buttonclass'] ) ) {
32 $this->mButtonClass = $info['buttonclass'];
33 }
34 if ( isset( $info['buttonid'] ) ) {
35 $this->mButtonId = $info['buttonid'];
36 }
37 if ( isset( $info['buttonname'] ) ) {
38 $this->mButtonName = $info['buttonname'];
39 }
40 if ( isset( $info['buttondefault'] ) ) {
41 $this->mButtonValue = $info['buttondefault'];
42 }
43 if ( isset( $info['buttontype'] ) ) {
44 $this->mButtonType = $info['buttontype'];
45 }
46 if ( isset( $info['buttonflags'] ) ) {
47 $this->mButtonFlags = $info['buttonflags'];
48 }
49 parent::__construct( $info );
50 }
51
52 public function getInputHTML( $value ) {
53 $attr = [
54 'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
55 'id' => $this->mButtonId,
56 ] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
57
58 return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
59 }
60
61 public function getInputOOUI( $value ) {
62 return new OOUI\ButtonInputWidget( [
63 'name' => $this->mButtonName,
64 'value' => $this->mButtonValue,
65 'type' => $this->mButtonType,
66 'label' => $this->mButtonValue,
67 'flags' => $this->mButtonFlags,
68 'id' => $this->mButtonId ?: null,
69 ] + OOUI\Element::configFromHtmlAttributes(
70 $this->getAttributes( [ 'disabled', 'tabindex' ] )
71 ) );
72 }
73
79 public function getElement( $element ) {
80 return $element . "\u{00A0}" . $this->getInputHTML( '' );
81 }
82}
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.
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.