I wrote an input filter for a Form by inheriting from InputFilter (class CustomInputFilter extends Zend\InputFilter\InputFilter).
By default, each form element is required. This means that I have to set required to False explicitly for all optional elements. How can I change the InputFilter such that all form elements are optional by default?
I use the Zend 2 framework.
I am not sure about it is possible the way you want using
InputFilter. I think this implies filtering and validating data. If any input field does not need to be required, then ZF have had the option ('required' => false). See another approachSo why is this? This is something that input field must exist but you can keep it empty. If you then put invalid data in it can then validate data too.