Revert "Convert Special:Search to OOUI"
[lhc/web/wiklou.git] / includes / htmlform / HTMLButtonField.php
1 <?php
2
3 /**
4 * Adds a generic button inline to the form. Does not do anything, you must add
5 * click handling code in JavaScript. Use a HTMLSubmitField if you merely
6 * wish to add a submit button to a form.
7 *
8 * @since 1.22
9 */
10 class HTMLButtonField extends HTMLFormField {
11 protected $buttonType = 'button';
12
13 /** @var array $mFlags Flags to add to OOUI Button widget */
14 protected $mFlags = array();
15
16 public function __construct( $info ) {
17 $info['nodata'] = true;
18 if ( isset( $info['flags'] ) )
19 $this->mFlags = $info['flags'];
20 parent::__construct( $info );
21 }
22
23 public function getInputHTML( $value ) {
24 $attr = array(
25 'class' => 'mw-htmlform-submit ' . $this->mClass,
26 'id' => $this->mID,
27 ) + $this->getAttributes( array( 'disabled', 'tabindex' ) );
28
29 return Html::input( $this->mName, $value, $this->buttonType, $attr );
30 }
31
32 /**
33 * Get the OOUI widget for this field.
34 * @param string $value
35 * @return OOUI\ButtonInputWidget
36 */
37 public function getInputOOUI( $value ) {
38 return new OOUI\ButtonInputWidget( array(
39 'name' => $this->mName,
40 'value' => $value,
41 'label' => $value,
42 'type' => $this->buttonType,
43 'classes' => array( 'mw-htmlform-submit', $this->mClass ),
44 'id' => $this->mID,
45 'flags' => $this->mFlags,
46 ) + $this->getAttributes( array( 'disabled', 'tabindex' ), array( 'tabindex' => 'tabIndex' ) ) );
47 }
48
49 protected function needsLabel() {
50 return false;
51 }
52
53 /**
54 * Button cannot be invalid
55 *
56 * @param string $value
57 * @param array $alldata
58 *
59 * @return bool
60 */
61 public function validate( $value, $alldata ) {
62 return true;
63 }
64 }