For the integration of Variable into Configuration builder, I want to have a 'Variable' Form Builder element that allows me to drag and drop a Variable registered variable form into any configuration page. See video for example of this working: http://www.youtube.com/watch?v=aMRTqb5_jDo
To do this, I needed to make a hook_element_info() entry to 'variable_form_element' as well as a theme item.
Patch attached in first comment, hope you consider this, otherwise I will be forced to do it in my own module which makes little sense and it wouldn't allow others to potentially leverage the element.
Configuration builder issue can be found at: #1686800: Ability to add form items for variables defined by the variables module
Comment | File | Size | Author |
---|---|---|---|
#8 | variable_form_element_element-1688586-8.patch | 1.06 KB | Deciphered |
#1 | variable_form_element_element-1688586-1.patch | 1.6 KB | Deciphered |
Comments
Comment #1
Deciphered CreditAttribution: Deciphered commentedPatch
Comment #2
bforchhammer CreditAttribution: bforchhammer commentedWow, this looks really cool :)
Is there a companion patch for the configuration builder module? I'm wondering how patch #1 is used...
Also note that the sub-module variable_realm makes it possible to store different values for different realms (e.g. languages, domains, ...). Here's a screenshot how this is currently handled on forms supported by the variable module. Ideally this should also be supported by the "configuration builder" module somehow... :)
Comment #3
Deciphered CreditAttribution: Deciphered commentedThere's still a few issues to iron out in for the Configuration builder side of things, but I will update the referenced issue with a patch or notice of the commit when it's ready.
The patch here is simply to allow for a 'variable_form_element' to be used, which is the element seen in the video. To use it you would simply add something like the following to a FAPI form:
And Variable will take care of making sure the correct FAPI form is rendered based on the chosen variable.
Configuration builder just uses system_settings_form() for the submissing of all configuration pages, so if Variable works with that it should work, if not, then I'm definitely open to suggestions.
Comment #4
bforchhammer CreditAttribution: bforchhammer commentedThanks for the quick explanation, makes sense. Patch looks fine to me, let's see what Jose says...
Yes, that's what variable works with so it looks like this should just work :)
Comment #5
Deciphered CreditAttribution: Deciphered commentedMarking this patch as needs work, it's not quite right yet. Primarily, the field ID doesn't get set.
Comment #6
Jose Reyero CreditAttribution: Jose Reyero commentedI am all for providing any API Config builder needs to work together.
However about this issue I don't really understand why we need a variable_form_element that renders a different variable widget (is that it?). I mean this is 'form widgets sourcery' that IMO belongs to config_builder module. (Unless it provides a feature that is reusable for other modules that config_builder, that I don't see.)
I think Variable should focus on providing variable lists / definitions / form elements that Config builder may need
Anyway though I don't understand this belongs to Variable if you guys insist on it, then ok, it can be here...
Btw, please take a look at my first 'integration try' (you both have commit access to this sandbox), see
http://drupal.org/sandbox/reyero/1689632
Comment #7
Deciphered CreditAttribution: Deciphered commentedI would have to say that it makes sense to be in Variable as it on it's own could be very useful to other modules, the ability to render a Site Name widget exactly as defined with just the code in #3 alone should be enough reason. All the logic as already in place, it's just a case of reregistering and rendering the element.
However, as I need the code to make Configuration builder work with Variable I would be happy to put it in Configuration builder, that would just mean that if anything wants to use the Variable based element they will first need to install my module and use an element named 'confiig_builder_variable_form_element'.
Comment #8
Deciphered CreditAttribution: Deciphered commentedUpdated patch, much better this time, I'm not sure why I couldn't get the #process approach working the first time around (and I did try) but it's working perfectly now.
Comment #9
mstrelan CreditAttribution: mstrelan commentedNow it works like the video when using config_builder from GitHub. I am getting these PHP notices though, not sure that they were there before.
Also when I first drag the variable element across it just shows an empty rectangle but IIRC the video shows something like "No variable selected".
Comment #10
Deciphered CreditAttribution: Deciphered commentedThose issues are fixed in an uncommitted version of Config Builder (variable branch), not related to this issue.
The empty variable bit is part of this patch though, it's something that I forgot, I'll update the patch shortly.
Comment #11
Deciphered CreditAttribution: Deciphered commentedMarking this back to needs review, opted to go with an alternative approach where a default #variable is chosen when placing the Form Builder element, which means that the message is no longer needed.
Comment #12
Jose Reyero CreditAttribution: Jose Reyero commentedSorry but I still don't get it. I mean how reusable is a widget that lets you select a variable and then changes the widget itself.
Really this should be in config_builder. You don't really need a long name, 'variable_form_element' should be fine, if you look at other modules defining form element types I don't think the use the module name prefix all the time.
Comment #13
Deciphered CreditAttribution: Deciphered commentedIt's your call to make, but I absolutely think it would be a useful addition to your module. If I want to make a standard FAPI form and have any variable in it's defined form without having to define that form myself, this would be the solution.
But as it's a requirement of the Configuration builder module I have little other choice but to define it myself.
Comment #14
Jose Reyero CreditAttribution: Jose Reyero commentedIf you want to add a variable element to your form, you just need to.
Really this 'magical form element' is a bad idea for building regular forms, though I can see it may be useful for config_builder or other modules that create form widgets. I don't think it will work for regular forms since building it like that you are missing the form element 'type' the variable should have.
Comment #15
sun