Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
ZendInput fallback value
Aug 11, 2015 @ 12:49:26

Rob Allen has posted another article about the ZendInput component of the Zend Framework (he talks about empty values here) this time covering the use of fallback values when the input doesn't contain the needed data.

Recently an issue was reported against ZendInputFilter where the reporter has discovered a regression where the fallback value wasn't being populated correctly. ?Matthew investigated, fixed it and asked me to review it. I was fascinated as I didn't realise (or had completely forgotten!) that ZendInput and ZendInputFilter supported fallback values so I looked into it and it turns out that it's simple and works exactly as its name implies.

He includes a simple example of a fallback for a name value set using the setFallback method on the Input object. He does point out one "wrinkle" in the functionality, however, dependent on the values set for required, allow_empty and continue_if_empty. Certain combinations could make the value either be returned differently than expected or not at all. He includes a small test script that shows the various combinations and what their expected output should look like.

tagged: zendinput fallback value zendframework2 tutorial

Link: http://akrabat.com/zendinput-fallback-value/

Rob Allen:
ZendInput and empty values
Aug 04, 2015 @ 10:49:15

Rob Allen has a post to his site to help clear up some confusion with how the ZendInput component handles "empty" between the required, allow_empty and continue_if_empty logic.

These settings define what happens when you try to validate an empty value for a given input. For ZendInput, empty means exactly equal to null, an empty string or an empty array.

He starts by outlining each of the three settings including both their default settings and its intent. He gets into a bit more detail on continue_if_empty as it has additional logic that depends on the results of the other two settings. He includes a small test application that cycles through a set of values and evaluates them through a ZendInput instance. The output is also included in the post so you can verify your system is seeing the same evaluation results.

tagged: zendinput empty value evaluation required allowempty continueifempty tutorial

Link: http://akrabat.com/zend-input-empty-values/

Trending Topics: