Skip to content

Commit

Permalink
Dev: Fix logic error with isValid and validation message
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Sep 5, 2016
1 parent dba2c4a commit 4c1a251
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions application/helpers/qanda_helper.php
Expand Up @@ -440,13 +440,13 @@ function composeQuestionText(array $ia, array $aQuestionAttributes)
$question_text['man_message'] = getMandatoryMessage($ia);

$_vshow = !isset($aQuestionAttributes['hide_tip']) || $aQuestionAttributes['hide_tip'] == 0; // whether should initially be visible - TODO should also depend upon 'hidetip'?
list($validation_msg, $isValid1) = validation_message($ia,$_vshow);
list($validation_msg, $isValid) = validation_message($ia,$_vshow);
$question_text['valid_message'] = $validation_msg;

list($file_valid_message, $isValid2) = getFileValidationMessage($ia);
$question_text['file_valid_message'] = $ia[4] == "|" ? $file_validation_msg : "";

if (!empty($question_text['man_message']) || !$isValid1 || !$isValid2 || !empty($question_text['file_valid_message']))
if (!empty($question_text['man_message']) || (!$isValid && !$isValid2) || !empty($question_text['file_valid_message']))
{
$question_text['input_error_class'] = ' input-error';// provides a class to style question wrapper differently if there is some kind of user input error;
}
Expand Down

3 comments on commit 4c1a251

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can move in event beforeQuestionRender

@olleharstedt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that event even be necessary after we've done question objects?

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, because some Questionattribute can use it easily. Not for {ANSWERS} but for {QUESTION_CLASS} or adding some css/js etc ...
really more easy at this place than in a question object.

Or : there are a "beforeRenderPartial" event for whole part + beforeGetEMvar (or templatereplace).

Please sign in to comment.