It would be nice if user could select other widget types instead of the "eplanation text".
Moreover, if we could allow users to select multiple fields (or maybe a group) as "explanation text", and allow different "explanaion fields" for each key, this module could become a full "conditional field" implementation. Is this too far from the initial purpose of the mudule?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | explainfield_2_alpha_2.zip | 7.96 KB | peterpoe |
| #6 | explainfield_2_alpha.zip | 7.38 KB | peterpoe |
| #5 | explainfield_2_alpha.patch | 33.66 KB | peterpoe |
Comments
Comment #1
snufkin commentedHow do you imagine the settings to the conditional widget? Would it be an already existing widget? Or with some AJAX mechanism the widget would be created on the explainfield settings page?
Comment #2
peterpoe commentedI think that the easiest option is to reference an existing group, which if selected would only be viewed (both on node view and node edit form) when a trigger key is selected. This way, the options for the group itself and the fields inside the group can be edited as usual from the Manage fields page. the explainfield module would only take care of hiding a group if the right trigger key is not selected!
I am already working on this (I have a tight schedule for my site!), I should have something working by the next day or two...
Comment #3
snufkin commentedit does sound like a sound extension of this module, so i would love to incorporate it. Since writing this was sponsored by a company, who are relying on it. i contacted them, to see if they are fine with this approach (probably yes). Personally im all in for it. I opened the branch 2.x, so please if you are to patch the module use that branch, so we can still have the 5.x-1.0 as stable.
Comment #4
snufkin commentedThe direction is okay, if you code it and it works I will also give it some testing, and I will commit it into the 2.x branch. Thanks a lot for these improvements, I think they are really cool.
We can provide the "explainfield" capability if someone is using "text field" as conditional field, and anyway there is the stable 1.0 branch that only provides a textfield.
Comment #5
peterpoe commentedHere it is. It's a patch against the last version in cvs (1.1.2.6.2.2).
This first attempt provides:
- Option to select a fieldgroup instead of the simple help text field in the explainfield configuration page.
- The selected fieldgroup will be visible (on both node edit and view) only if one of the provided trigger keys is selected by the user.
The problem is, that I had to use some horrible hacks in form_alter and in nodeapi, because the "required" fields were always invalidating the form, even when they weren't selected. So I altered node_form unsetting all required fields in the group, storing the required fields in a form property (#explainfield_required_fields), then doing a custom check on those fields on nodeapi case: validate. Ugh.
The form_alter implementation is the worst, because I did it first. In nodeapi I came up with a more general solution to the "find required cck fields" problem, which is contained in the explainfield_check_required function. Maybe we can change form_alter to use this function too.
It seems to work with the widgets included in cck, but it has to be tested with other fields... There are millions other way to improve, and lacks the final piece: let users select multiple fields for each trigger_key!
Comment #6
peterpoe commentedI forgot to include the .install file, which is needed to set the weight of the module over the weight of the fieldgroup module.
Comment #7
peterpoe commentedIt seems that I used some javascript which depends on the jquery_update.module. I'll fix this.
Comment #8
peterpoe commentedThere we go. Fixed a lot of stuff.