Closed (fixed)
Project:
Webform Hints
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Aug 2013 at 18:26 UTC
Updated:
4 Sep 2013 at 16:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
adamzimmermann commentedThere might be a better way to check for fields items that are theme configuration other than just checking for '#', but I couldn't find a Drupal function that seemed to do what I needed.
Comment #2
adamzimmermann commentedI thought this through some more, and using
element_childrenwouldn't actually be better in my opinion. It would add the overhead of that function, and then require a loop that works with the flipped array keys, which is always annoying. Additionally, we would be callingwebform_hints_add_titleusing a different syntax, introducing more opportunities for error. So I think a quick check at the beginning of the function call is the simplest and probably most efficient solution here.Thoughts?
I renamed the patch using the correct naming syntax and re-attached it.
Comment #3
guschilds commentedelement_childrenmay bring a sliver of overhead, but it avoids callingwebform_hints_add_titleon a decent chunk of irrelevant items. You're right, though, the current implementation that usesarray_walkmakes it hard to useelement_children. I've attached a patch that switches that up. This is totally bikeshedding and I only did it becauseelement_childrenfeels more like "the Drupal way" to me.Even if you disagree, there are a few things worth noting:
Your patch introducedisset()intoif (isset($element['#required']) && !$element['#required']) {, but if it isn't set that probably means the element isn't required. This statement should beTRUEwhen it isn't, so using OR makes more sense, right?// Skip the boolean #tree./if (is_array($element)) {was to do the same thing you're now doing with your check (and I'm doing withelement_children), so that is no longer needed. I believe that can just becomeelse, right?Marking as needs work. Feel free to decide whatever route you want to take, but please consider the two bulleted changes. Thanks!
Comment #4
guschilds commentedHmm. On second thought, ignore the suggested change to the required logic. Didn't think that one through. :)
The
is_arraycheck also doesn't hurt, I suppose. It could be moved up with the$key[0]check. If not, please update the comment.Sorry bout that!
Comment #5
adamzimmermann commentedAlright. I think this is the one.
Comment #6
guschilds commentedI'd agree. Just reviewed/tested it and it works well. Thanks for this!
Comment #7
adamzimmermann commentedFix committed here.