Closed (fixed)
Project:
GMap3 Tools
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Sep 2013 at 10:23 UTC
Updated:
16 Oct 2013 at 21:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
s_leu commentedHere's a patch that makes enables calling code to pass a form and attaches the js to it, if a form is passed.
Comment #2
s_leu commentedThe related issue in salsa_entity is #2097431: Map on event page breaks on validation failure
Comment #3
berdirThat's a somewhat "creative" solution. Wondering if it would make more sense to add a new function that returns a render array and @deprecate this one. Easier to port to D8, where drupal_add_js() will go away.
Comment #4
s_leu commentedAdding a patch as which adds a separate function for attaching the js to forms, also did some refactoring to prevent redundant code.
Comment #5
berdirtype hint the function argument with array &$form, then the check here isn't necessary.
Drupal is intelligent enough to avoid duplicates. Even easier if it would be a library, but that's another topic.
In fact, when you think about caching, you want to ensure that each partial render array has all the information it needs to be displayed.
A cached form won't run this function again, if there would be two calls/forms, the second one would get an incomplete render array and might not render correctly.
Comment #6
s_leu commentedAdding the suggested changes
Comment #7
pivica commentedChecked patch from #6, looking good, committed to 7.x-1.x branch.
@s_leu, @Berdir thx for your work.