zendframework / zend-inputfilter

InputFilter component from Zend Framework
BSD 3-Clause "New" or "Revised" License
64 stars 50 forks source link

Patch for integer indexed nested InputFilters defined in input_filter_specs #68

Closed Blinden closed 8 years ago

Blinden commented 8 years ago

Apigiltiy uses integer indexed arrays and nested input_filter_specs only work with associative arrays!

In Apigility I have a code-connected resource with an embedded collection of items. For validation I defined an input_filter_spec with a nested CollectionInputFilter using associative arrays. Problems started when I manually defined this filter in zf-content-validation for the resource. At first integration worked perfect except there where no fields visible in Apigility but the filter worked incl. the embedded items. But when I added a field it removed all the input_filter_specs of the filter. Next I defined my filter using an integer-index and the filter stopped working on the embedded items because the nested input filter has no name property.

This patch tries to solve this by allowing input_filter_specs to have a name entry.

To minimize side effects or possible BC breaks the name is used only on integer indexed specs with a type defined and the name itself is a string.

A side effect of the patch is Apigility shows all fields but silently breaks (Angular exception) when trying to add a filter. Adding a validator works but is faulty. It should not be difficult to prevent Apigility from modifying fields with nested filters. Developers of resources with nested entities will be helped and are already used to do manual changes.