Merge "ApiQueryRevisions: Remove bogus query optimization"
[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 public function __construct( $info ) {
14 $info['nodata'] = true;
15 parent::__construct( $info );
16 }
17
18 public function getInputHTML( $value ) {
19 $attr = array(
20 'class' => 'mw-htmlform-submit ' . $this->mClass,
21 'id' => $this->mID,
22 ) + $this->getAttributes( array( 'disabled', 'tabindex' ) );
23
24 return Html::input( $this->mName, $value, $this->buttonType, $attr );
25 }
26
27 /**
28 * Get the OOUI widget for this field.
29 * @param string $value
30 * @return OOUI\ButtonInputWidget
31 */
32 public function getInputOOUI( $value ) {
33 return new OOUI\ButtonInputWidget( array(
34 'name' => $this->mName,
35 'value' => $value,
36 'type' => $this->buttonType,
37 'classes' => array( 'mw-htmlform-submit', $this->mClass ),
38 'id' => $this->mID,
39 ) + $this->getAttributes( array( 'disabled', 'tabindex' ), array( 'tabindex' => 'tabIndex' ) ) );
40 }
41
42 protected function needsLabel() {
43 return false;
44 }
45
46 /**
47 * Button cannot be invalid
48 *
49 * @param string $value
50 * @param array $alldata
51 *
52 * @return bool
53 */
54 public function validate( $value, $alldata ) {
55 return true;
56 }
57 }