From: Brad Jorsch Date: Thu, 31 Jul 2014 18:04:00 +0000 (-0400) Subject: Improve hidden field validation X-Git-Tag: 1.31.0-rc.0~14007^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=788526c2d1a4a9e32722c0a26b4a5027f00aa9bb;hp=4169b4f42502ca1956f7a7253b5f54e1901e7821;p=lhc%2Fweb%2Fwiklou.git Improve hidden field validation Hidden fields are supposed to be ignored during validation; more completely ensure this by checking in HTMLForm::trySubmit before calling validate. Also, more properly handle HTMLCheckFields in the isHidden check by casting their booleans to strings. Bug: 68132 Change-Id: I84f8239c299727b773015643048eed4684417733 --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 6cf8d0a7eb..59e577b7ab 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -467,6 +467,9 @@ class HTMLForm extends ContextSource { if ( !empty( $field->mParams['nodata'] ) ) { continue; } + if ( $field->isHidden( $this->mFieldData ) ) { + continue; + } if ( $field->validate( $this->mFieldData[$fieldname], $this->mFieldData ) diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 7e4b15b051..7db5ebcefb 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -113,7 +113,7 @@ abstract class HTMLFormField { } $data = $data[$key]; } - $testValue = $data; + $testValue = (string)$data; break; }