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

Dewdrop/Fields/Helper/InputFilter's addInput doesn't always respect a field's required value #60

Open
matthewmcdonald opened this issue Sep 9, 2015 · 0 comments

Comments

@matthewmcdonald
Copy link
Contributor

I've discovered that for many-to-many relationships, the $input returned here always has required set to true, even when $field->isRequired() is false:

public function addInput(FieldInterface $field)
{
    $callback = $this->getFieldAssignment($field);
    $input    = call_user_func($callback);

I've fixed this locally by adding this change immediately afterwards:

if ($field instanceof DbField && 
    $input instanceof Zend\InputFilter\Input && 
    $input->isRequired() != $field->isRequired()
) {
    $input->setRequired($field->isRequired());
}

Is there a reason why $input->isRequired() would ever not be equal to $field->isRequired()?

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

1 participant