X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLButtonField.php;h=84719a7adddd88661b6f1146139781fd11c1f5a6;hb=a5230acd936b5b9270037c35b9d2d419f4c8d9a6;hp=500b5020c828e4848d9b48b6dfeca84b2b104f1c;hpb=4c1639f33a1ae9e0d1a072127b248ca83e8381f5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLButtonField.php b/includes/htmlform/fields/HTMLButtonField.php index 500b5020c8..84719a7add 100644 --- a/includes/htmlform/fields/HTMLButtonField.php +++ b/includes/htmlform/fields/HTMLButtonField.php @@ -13,6 +13,9 @@ * of the value from 'default'. Overrides 'buttonlabel-raw'. * - buttonlabel-raw: HTMLto display for the button display text, instead * of the value from 'default'. + * - formnovalidate: Set to true if clicking this button should suppress + * client-side form validation. Used in HTMLFormFieldCloner for add/remove + * buttons. * * Note that the buttonlabel parameters are not supported on IE6 and IE7 due to * bugs in those browsers. If detected, they will be served buttons using the @@ -27,29 +30,36 @@ class HTMLButtonField extends HTMLFormField { /** @var array $mFlags Flags to add to OOUI Button widget */ protected $mFlags = []; + protected $mFormnovalidate = false; + public function __construct( $info ) { $info['nodata'] = true; + + $this->setShowEmptyLabel( false ); + + parent::__construct( $info ); + if ( isset( $info['flags'] ) ) { $this->mFlags = $info['flags']; } + if ( isset( $info['formnovalidate'] ) ) { + $this->mFormnovalidate = $info['formnovalidate']; + } + # Generate the label from a message, if possible if ( isset( $info['buttonlabel-message'] ) ) { $this->buttonLabel = $this->getMessage( $info['buttonlabel-message'] )->parse(); } elseif ( isset( $info['buttonlabel'] ) ) { - if ( $info['buttonlabel'] === ' ' ) { + if ( $info['buttonlabel'] === ' ' || $info['buttonlabel'] === "\u{00A0}" ) { // Apparently some things set   directly and in an odd format - $this->buttonLabel = ' '; + $this->buttonLabel = "\u{00A0}"; } else { $this->buttonLabel = htmlspecialchars( $info['buttonlabel'] ); } } elseif ( isset( $info['buttonlabel-raw'] ) ) { $this->buttonLabel = $info['buttonlabel-raw']; } - - $this->setShowEmptyLabel( false ); - - parent::__construct( $info ); } public function getInputHTML( $value ) { @@ -71,6 +81,7 @@ class HTMLButtonField extends HTMLFormField { 'type' => $this->buttonType, 'name' => $this->mName, 'value' => $this->getDefault(), + 'formnovalidate' => $this->mFormnovalidate, ] + $this->getAttributes( [ 'disabled', 'tabindex' ] ); if ( $this->isBadIE() ) {