MediaWiki  master
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 }
HTMLFormFieldWithButton\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
Definition: HTMLFormFieldWithButton.php:61
HTMLFormFieldWithButton\$mButtonFlags
string[] $mButtonFlags
Value for the button in this field.
Definition: HTMLFormFieldWithButton.php:24
HTMLFormFieldWithButton\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLFormFieldWithButton.php:52
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:667
HTMLFormFieldWithButton\__construct
__construct( $info)
Stable to call Initialise the object.Stable to call Associative Array. See HTMLForm doc for syntax....
Definition: HTMLFormFieldWithButton.php:30
HTMLFormFieldWithButton\getElement
getElement( $element)
Combines the passed element with a button.
Definition: HTMLFormFieldWithButton.php:79
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:9
HTMLFormFieldWithButton
Enables HTMLFormField elements to be build with a button.
Definition: HTMLFormFieldWithButton.php:7
HTMLFormFieldWithButton\$mButtonName
string $mButtonName
Name the button in this field.
Definition: HTMLFormFieldWithButton.php:15
HTMLFormFieldWithButton\$mButtonValue
string $mButtonValue
Value for the button in this field.
Definition: HTMLFormFieldWithButton.php:21
HTMLFormFieldWithButton\$mButtonType
string $mButtonType
Type of the button in this field (e.g.
Definition: HTMLFormFieldWithButton.php:18
HTMLFormFieldWithButton\$mButtonClass
string $mButtonClass
CSS class for the button in this field.
Definition: HTMLFormFieldWithButton.php:9
HTMLFormFieldWithButton\$mButtonId
string int $mButtonId
Element ID for the button in this field.
Definition: HTMLFormFieldWithButton.php:12
HTMLFormField\getAttributes
getAttributes(array $list)
Returns the given attributes from the parameters Stable to override.
Definition: HTMLFormField.php:1039