Skip to content

Context doesn't allow access to nested data #752

@tomaszkane

Description

@tomaszkane

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions