Skip to content

Commit

Permalink
Fixes issue of over-refreshing invalid controls on ajax posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeho committed Nov 8, 2009
1 parent 70c3950 commit 59d2d28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions includes/qcodo/_core/qform/QControlBase.class.php
Expand Up @@ -1204,6 +1204,8 @@ public function __set($strName, $mixValue) {
case "Enabled":
try {
$this->blnEnabled = QType::Cast($mixValue, QType::Boolean);
$this->strValidationError = null;
$this->strWarning = null;
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
Expand Down Expand Up @@ -1236,6 +1238,8 @@ public function __set($strName, $mixValue) {
case "Visible":
try {
$this->blnVisible = QType::Cast($mixValue, QType::Boolean);
$this->strValidationError = null;
$this->strWarning = null;
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
Expand Down
11 changes: 6 additions & 5 deletions includes/qcodo/_core/qform/QFormBase.class.php
Expand Up @@ -236,9 +236,8 @@ public static function Run($strFormId, $strAlternateHtmlFile = null) {
// Reset the modified/rendered flags and the validation
// in ALL controls
$objControl->ResetFlags();
$objControl->ValidationReset();
}

// Trigger Run Event (if applicable)
$objClass->Form_Run();

Expand Down Expand Up @@ -281,7 +280,7 @@ public static function Run($strFormId, $strAlternateHtmlFile = null) {
// Trigger Create Event (if applicable)
$objClass->Form_Create();
}

// Trigger PreRender Event (if applicable)
$objClass->Form_PreRender();

Expand Down Expand Up @@ -457,7 +456,6 @@ protected function RenderAjax() {

// close Command collection
$strToReturn .= '</commands>';

$strContents = trim(ob_get_contents());

if (strtolower(substr($strContents, 0, 5)) == 'debug') {
Expand Down Expand Up @@ -684,6 +682,7 @@ protected function ValidateControlAndChildren(QControl $objControl) {
$blnToReturn = true;

// Check the Control Itself
$objControl->ValidationReset();
if (!$objControl->Validate()) {
$objControl->MarkAsModified();
$blnToReturn = false;
Expand Down Expand Up @@ -784,11 +783,13 @@ protected function TriggerActions($strControlIdOverride = null) {
// Get all the children of ParentObject
foreach ($this->GetChildControls($objParentObject) as $objControl)
// Only Enabled and Visible and Rendered controls that are children of ParentObject should be validated
if (($objControl->Visible) && ($objControl->Enabled) && ($objControl->RenderMethod) && ($objControl->OnPage))
if (($objControl->Visible) && ($objControl->Enabled) && ($objControl->RenderMethod) && ($objControl->OnPage)) {
$objControl->ValidationReset();
if (!$objControl->Validate()) {
$objControl->MarkAsModified();
$blnValid = false;
}
}

// No Validation Requested
} else {}
Expand Down

0 comments on commit 59d2d28

Please sign in to comment.