As we discussed on IRC. The solution is to let other modules know in what form function this file lives through $form_state. Something like $form_state['#delegator']['form_function_file'].
Right now this only happens on node forms so you could add it to delegator_node_edit() only. But generic is better, because ctools will probably be used for other forms as well in the future.
Please ping me when you've implemented this :) Thanks!
The relevant portion of our chat:
WimLeers:
merlinofchaos: this is the logic in hierarchical_select_json that takes care of this
01:53WimLeers:
http://pastie.textmate.org/private/j56ytfai4r9oornyrn6q
01:53WimLeers:
It assumes that the include file contains the form definition function. Which is acceptable to assume, in 99% of the forms. But not for delegator I suppose.
01:54merlinofchaos:
Riiiight.
01:54merlinofchaos:
Interesting dilemma!
01:54merlinofchaos:
Hm.
merlinofchaos:
This isn't just delegator powered forms, it's any time the form isn't in the file...er, where do you get that filename?
01:56WimLeers:
merlinofchaos: http://pastie.textmate.org/private/mcktulgvgu8bniqgvw6hwq
01:57merlinofchaos:
I see.
01:57WimLeers:
merlinofchaos: It *is* just delegator powered forms, because delegator is adding another layer of indirection: you have to do something special before you can use the form definition function.
01:58merlinofchaos:
I can think of hacky solutions but not a good permanent solution just yet.
01:58merlinofchaos:
The hacky solution is: if (!function_exists($form_id)) { ... is it a node form? Include node.pages.inc. etc ... }
01:58WimLeers:
hehe
01:58WimLeers:
But can't delegator be applied to forms other than node forms too?
01:59merlinofchaos:
Right now just node form, in the future user edit form.
01:59merlinofchaos:
And other made up forms, I suppose.
02:01merlinofchaos:
Ok, a slightly more elegant solution is that I can stick something on $form_state for you.
02:01WimLeers:
That'd be great.
02:01WimLeers:
something like $form_state['#delegator']['form_function_file']
emspace left the chat room.
02:02merlinofchaos:
Can do. It doesn't have to be delegator specific, but we can.
Comments
Comment #1
chawl commentedsubs
Comment #2
merlinofchaos commentedI have implemented this in -dev and it will go out in beta2.
I called it $form_state['form_load_files'] because I feel it shouldn't be delegator specific, and HS can ask any other module that does the same thing to include such a thing in order to play nice.
I made this an array so that multiple files can be loaded if necessary. The code needed to use it should just be:
Note that I put it on $form_state not directly in storage, so HS will have to copy that to its storage so it can find it when loading the cached form. Once HS implements its half, we should be able to be happy again.