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

Inputfilter getValues() returns the field which is not in input data #9

Open
weierophinney opened this issue Dec 31, 2019 · 4 comments

Comments

@weierophinney
Copy link
Member

$specs =  array(
    'title' => array(
        'name'       => 'title',
        'filters' => array(
            array(
                'name' => 'Zend\Filter\StringToLower',
            ),
        ),
    ),
);

$inputFilterFactory = new \Zend\InputFilter\Factory();
$inputFilter = $inputFilterFactory->createInputFilter($specs);
$data = array(
    'title' => 'TEST',
);
$inputFilter->setData($data);
var_dump($inputFilter->getValues());

Expected Output:

array(1) {
  ["title"]=>
  string(3) "test"
}
$data = array(
    'xyz' => 'something',
);
$inputFilter->setData($data);
var_dump($inputFilter->getValues());

Unexpected (or it is intentional?) Output:

array(1) {
  ["title"]=> NULL
}

Originally posted by @metanav at zendframework/zend-inputfilter#66

@weierophinney
Copy link
Member Author

@weierophinney
Copy link
Member Author

One possible option is to add an argument to getValues() for to return all inputs or only the inputs with data set.


Originally posted by @Maks3w at zendframework/zend-inputfilter#66 (comment)

@weierophinney
Copy link
Member Author

Another option is add a new method for return only the fields with data (method name is more expressive rather than arguments values).


Originally posted by @Maks3w at zendframework/zend-inputfilter#66 (comment)

@weierophinney
Copy link
Member Author

That would not stop input filter to do filtering of the input which is not set. The new method would just do one more filtering of unset data.


Originally posted by @metanav at zendframework/zend-inputfilter#66 (comment)

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