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

Moving Collection Count Check to isValid Step. #29

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Moving Collection Count Check to isValid Step. #29

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Member

Would it make sense to remove the thrown DomainException when calling $form->setData() (here, here, and here) and add a validator that will check for this? Returning an accurate error message becomes very ugly when using multiple collections on one form.

From:

try{
    $form->setData($data);

    if($form->isValid()){
        ...
    }else{
        ...
    }
}catch(DomainException $e){
    //If I had multiple collections, I would need to check $data to see which one caused the exception.
    $errors = [
        'myCollection' => [
             'count' => 'Some error message'
        ]
    ];
}

To:

$form->setData($data);

if($form->isValid()){
    ...
}else{
    ...
}

Originally posted by @ghost at zendframework/zend-form#97

@weierophinney
Copy link
Member Author

Honestly, no idea. 😄

Can you provide a pull request that demonstrates how you'd like to consume this from a userland perspective? That may help us better understand where it's falling short, and potentially other directions for addressing it.

Thanks!


Originally posted by @weierophinney at zendframework/zend-form#97 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant