Merge "Stop using the unholy trinity in DatabaseError"
[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 );
23
24 if ( !empty( $this->mParams['disabled'] ) ) {
25 $attr['disabled'] = 'disabled';
26 }
27
28 return Html::input( $this->mName, $value, $this->buttonType, $attr );
29 }
30
31 protected function needsLabel() {
32 return false;
33 }
34
35 /**
36 * Button cannot be invalid
37 *
38 * @param $value String
39 * @param $alldata Array
40 *
41 * @return Bool
42 */
43 public function validate( $value, $alldata ) {
44 return true;
45 }
46 }