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

Context doesn't allow access to nested data #752

Open
tomaszkane opened this issue Dec 6, 2024 · 0 comments
Open

Context doesn't allow access to nested data #752

tomaszkane opened this issue Dec 6, 2024 · 0 comments
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug

Comments

@tomaszkane
Copy link
Contributor

tomaszkane commented Dec 6, 2024

What steps will reproduce the problem?

public function getRules(): array
{
    return [
        'submitForVerification' => [
            new Required,
            new BooleanValue,
        ],
        'tasks' => [
            new Each(
                new Nested([
                    'push' => [
                        new Nested([
                            'isEnabled' => [
                                new Required(when: fn() => $this->submitForVerification),
                                new BooleanValue,
                            ],
                            'content' => [
                                new Required(when: [???]),
                            ],
                        ])
                    ],
                ])
            )
        ],
    ];
}

What is the expected result?

I can set Required validator for content dependent on his sibling isEnabled value.

What do you get instead?

It cannot be done? Or it'll be ugly solution.

Additional info

Q A
Version 2.1.x
PHP version 8.2
Telegram message https://t.me/yii3en/10708
@samdark samdark added type:bug Bug status:ready for adoption Feel free to implement this issue. labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants