From: John Du Hart Date: Sat, 8 Oct 2011 19:13:35 +0000 (+0000) Subject: Add a method to HTML for getting just the HTML (As opposed to passing it right to... X-Git-Tag: 1.31.0-rc.0~27184 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=2a6150cda4a89b3acd075cfaf711f3c5cbf5ac00;p=lhc%2Fweb%2Fwiklou.git Add a method to HTML for getting just the HTML (As opposed to passing it right to Output Also, if a field is marked as required, it should still be checked to see if it's empty before going to the callback. Don't like that behavior? Don't mark it as required. --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 78a59f4863..63a5d5966e 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -374,6 +374,15 @@ class HTMLForm { * @param $submitResult Mixed output from HTMLForm::trySubmit() */ function displayForm( $submitResult ) { + $this->getOutput()->addHTML( $this->getHTML( $submitResult ) ); + } + + /** + * Returns the raw HTML generated by the form + * @param $submitResult Mixed output from HTMLForm::trySubmit() + * @return string + */ + function getHTML( $submitResult ) { # For good measure (it is the default) $this->getOutput()->preventClickjacking(); $this->getOutput()->addModules( 'mediawiki.htmlform' ); @@ -389,11 +398,7 @@ class HTMLForm { $html = $this->wrapForm( $html ); - $this->getOutput()->addHTML( '' - . $this->mPre - . $html - . $this->mPost - ); + return '' . $this->mPre . $html . $this->mPost; } /** @@ -832,14 +837,14 @@ abstract class HTMLFormField { * @return Mixed Bool true on success, or String error to display. */ function validate( $value, $alldata ) { - if ( isset( $this->mValidationCallback ) ) { - return call_user_func( $this->mValidationCallback, $value, $alldata ); - } - if ( isset( $this->mParams['required'] ) && $value === '' ) { return wfMsgExt( 'htmlform-required', 'parseinline' ); } + if ( isset( $this->mValidationCallback ) ) { + return call_user_func( $this->mValidationCallback, $value, $alldata ); + } + return true; }