Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

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

Open
metanav opened this issue Sep 5, 2015 · 5 comments
Open

Comments

@metanav
Copy link

metanav commented Sep 5, 2015

$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
}
@Maks3w
Copy link
Member

Maks3w commented Sep 5, 2015

Related to zendframework/zendframework#7440

@Maks3w Maks3w added the BC Break label Sep 5, 2015
@Maks3w Maks3w modified the milestone: 3.0.0 Sep 5, 2015
@Maks3w Maks3w removed the BC Break label Sep 5, 2015
@Maks3w
Copy link
Member

Maks3w commented Sep 5, 2015

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

@Maks3w
Copy link
Member

Maks3w commented Sep 5, 2015

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

@metanav
Copy link
Author

metanav commented Sep 5, 2015

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.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-inputfilter; a new issue has been opened at laminas/laminas-inputfilter#9.

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

No branches or pull requests

3 participants