Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Servier-Side Validation is not disabled on hidden by condition field. #29

Open
dkd-kaehm opened this issue Oct 24, 2018 · 7 comments

Comments

@dkd-kaehm
Copy link

dkd-kaehm commented Oct 24, 2018

Caused by
2f4d0d3#diff-70a09ddce344d5780d1e799fa2eb26f7R64

        $formUid = $form->getUid();
        $pageUid = $parentPage->getUid();
        $marker = $field->getMarker();
        
        if (ConfigurationUtility::isReplaceIrreWithElementBrowserActive()) {
            /** @var Page $page */
            foreach ($form->getPages() as $page) {
                /** @var Field $field */
                foreach ($page->getFields() as $field) {
                    if (!empty($arguments[$formUid][$pageUid][$marker][Condition::INDEX_ACTION])) {
                        if ($arguments[$formUid][$pageUid][$marker][Condition::INDEX_ACTION] ===
                            Condition::ACTION_HIDE_STRING) {
                            return;
                        }
                    }
                }
            }

the array keys in each loop are the same

@einpraegsam
Copy link
Collaborator

Thx, seems really a bit strange. Nevertheless I did not recognize an issue on my testsystem. Can you pls give me a hint how to reproduce the issue?

@dkd-kaehm
Copy link
Author

dkd-kaehm commented Oct 25, 2018

Hi,
trying to send form with required/mandatory marked field which is hidden by cond.
You should get validation errors from server.

But expected behaviour is, that hidden by cond fields should NOT be validated on server-side.

@nicozerr
Copy link

I had the same problem, but only if I was logged in BE.
Not logged in BE, the hidden mandatory field is well-ignored.

@sarahhoppe
Copy link

Same here.
Are there any solutions?
I have the problem, whether I'm logged in or not

@rengaw83
Copy link

There are some confusing dependencies.

powermail_cond 6 requires powermail 6.1.
When you use powermail_cond > 6 and powermail < 6.1 it will not work.
For older projects with powermail 6 you has to use powermail_cond 5.
Otherwise the server side validation on submit does not work.

@CarstenKoehler
Copy link

CarstenKoehler commented Sep 1, 2020

I had the same behaviour on my website - took me a while to debug and understand

When creating the form, the conditions get attached to the fe_user session Object
My fe_user object is not persistent as it seems, the cookie "fe_typo_user" has a different value in each request. (Seems this is default behaviour of Typo3 to avoid session fixations etc.)

Oddly enough, when tracing that behaviour it all seems fine in the Database - the session values get transferred from one Session(id) to the next Session(id).

Nevertheless all attempts to retrieve the session values via return $feUser->getSessionData('tx_powermail_cond'); in the SessionAwareValidator fail.

I traced it back to TYPO3\CMS\Core\Authentication\AbstractUserAuthentication class - the powermail_cond values always seem to be NULL

As soon as I got a valid FE-Login everything works as it should...

The PHP-Session stays the same, so setting and getting the values via $_SESSION['tx_powermail_cond'] works like a charm.

Any help is appreciated ..

@christophlehmann
Copy link
Contributor

I'm on an older version, but the code looks the same.

With active isReplaceIrreWithElementBrowserActive() server-side validation might not work, because $field needs to have another name in

https://github.com/einpraegsam/powermail_cond/blob/9.0.4/Classes/Domain/Validator/ConditionAwareValidator.php#L47

After the foreach loop, $field is always the last field of the last page (i guess always the submit button) and the parent method is thus always called for the submit field.

This behaviour didn't changed with 2f4d0d3#diff-70a09ddce344d5780d1e799fa2eb26f7R64

christophlehmann pushed a commit to christophlehmann/powermail that referenced this issue Jun 6, 2023
…eIrreWithElementBrowserActive()

While iterating over $page->getFields() its cursor is forwarded when ConfigurationUtility::isReplaceIrreWithElementBrowserActive()
in \In2code\PowermailCond\Domain\Validator\ConditionAwareValidator::isValidFieldInMandatoryValidation() and thus, fields are skipped.

Setup
* Page with title,firstname,lastname
* Page with submit button

Without this, only title and submit button is validated.

Relates: in2code-de/powermail_cond#29
christophlehmann pushed a commit to christophlehmann/powermail that referenced this issue Jun 6, 2023
…eIrreWithElementBrowserActive()

While iterating over $page->getFields() its cursor is forwarded when ConfigurationUtility::isReplaceIrreWithElementBrowserActive()
in \In2code\PowermailCond\Domain\Validator\ConditionAwareValidator::isValidFieldInMandatoryValidation() and thus, fields are skipped.

Setup
* Page with title,firstname,lastname
* Page with submit button

Without this, only title and submit button is validated.

Resolves: in2code-de/powermail_cond#29
christophlehmann pushed a commit to christophlehmann/powermail_cond that referenced this issue Jun 6, 2023
With ConfigurationUtility::isReplaceIrreWithElementBrowserActive() $field passed to
parent::isValidFieldInMandatoryValidation() is always the last field of the last page.

Relates: in2code-de#29
christophlehmann pushed a commit to christophlehmann/powermail_cond that referenced this issue Jun 6, 2023
Due to nested iteration over the same ObjectStorage the cursor becomes wrong.
This is fixed by using an array.

Relates: in2code-de#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants