(bug 47070) check content model namespace on import.
[lhc/web/wiklou.git] / includes / htmlform / HTMLButtonField.php
1 <?php
2 /**
3 * Adds a generic button inline to the form. Does not do anything, you must add
4 * click handling code in JavaScript. Use a HTMLSubmitField if you merely
5 * wish to add a submit button to a form.
6 *
7 * @since 1.22
8 */
9 class HTMLButtonField extends HTMLFormField {
10 protected $buttonType = 'button';
11
12 public function __construct( $info ) {
13 $info[ 'nodata' ] = true;
14 parent::__construct( $info );
15 }
16
17 public function getInputHTML( $value ) {
18 $attr = array(
19 'class' => 'mw-htmlform-submit ' . $this->mClass,
20 'id' => $this->mID,
21 );
22
23 if ( ! empty( $this->mParams[ 'disabled' ] ) ) {
24 $attr[ 'disabled' ] = 'disabled';
25 }
26
27 return Html::input( $this->mName, $value, $this->buttonType, $attr );
28 }
29
30 protected function needsLabel() {
31 return false;
32 }
33
34 /**
35 * Button cannot be invalid
36 *
37 * @param $value String
38 * @param $alldata Array
39 *
40 * @return Bool
41 */
42 public function validate( $value, $alldata ) {
43 return true;
44 }
45 }