Hi-
Before I go off and start writing my own small library of helper functions, I thought I would ask first if these already exist. Let me give you an example or two I'm about to write just to see if I'm heading down the wrong path. For these examples the context is I'm writing some custom code that will get used with the gform_after_submission() hook.
Example 1: My code needs to iterate over the responses to a checkbox field and do something to each option that has been checked off. gform_after_submission() gets handed an entry object. As far as I can tell, there's no predefined way to say "Given this checkbox field, hand me back an array with the items that have been checked off." I've looked at the GF code itself (specifically at the code that makes replaces the {all_fields} merge field with a spiffy HTML table), but nothing in the code jumped out as a function the GF developers have intentionally exposed to the world for doing something like this.
Being able to get the responses back from a checklist field seems really handy (especially since the entry object stores the responses in a flat data structure. Getting all of the entries associated with a single checkbox field seems to require actually string matching against key names, which seems a bit sub-optimal to me).
Example 2: the current method of retrieving values back from a form seems a bit fragile to me because one has to use essentially indices (i.e. form IDs), instead of names. This means we work with:
$entry['1.1'] instead of $entry['first_name']
I suspect GF tries not to ever reuse IDs if it can help it, but I'm not clear if it will do so if you go back and re-edit a form or perhaps move the form and edit it. In any case, I know which of the two forms I'd prefer to read in my code.
Given that you can get the field name -> ID mapping, it seems like writing a function that retrieves the value of a field from the $entry object should be relatively easy to write. It would be swell to say get_field_value('first_name'). I realize this might break if you have two fields with the same name, but then perhaps one could use an optional second parameter to disambiguate.
Neither of these functions seem really hard (even to a PHP dabbler like myself), but it would be spiffy if either they already shipped in the product or were documented some place in a "helpful utility functions" part of the doc. Do they and other helper functions exist? (or should I punt this to "Feature Requests")
Thanks!
-- dNb
P.S. On the plus side, the GF code itself is nicely structured and a pleasure to read.