Hi,
I have been using this module and it is excellent! In an attempt to skin the checkboxes and radio buttons (including the labels), I discovered that the wrapper div that encapsulates the label and the checkbox items does not have a div ID, it only has class="form-item", unlike the other form items. I was wondering if this is something that can be implemented in the module or at least direct me to the line of code where it should be changed.
I have attached a sample of the outputted code for your review.
Any help is greatly appreciated!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | profile_checkboxes-686944-3.jpg | 52.16 KB | rocketeerbkw |
| #1 | profile-boxes-div-id.jpg | 235.05 KB | sol1313 |
Comments
Comment #1
sol1313 commentedComment #2
johnhanley commentedThanks for reporting this. Yeah, you're right. The ID is missing from the wrapper div.
If you look in profile_checkboxes.module starting at line 58, the only form field attribute values changed for each case (i.e. radio button, checkboxes) are #type and #default_value. I believe this is indeed responsible for the missing ID though because the default field outputs all contain an ID for each corresponding wrapper div.
I don't understand why this is happening and unfortunately my current schedule doesn't provide me the time to debug right now. I would be appreciative if you or someone could diagnose the problem and report back here with your findings and perhaps provide a patch or code sample to remedy it.
Comment #3
rocketeerbkw commentedI looked at this, and I don't think it's a bug.
If you expand the
<div class="form-radios">you'll find that each<input type="radio">is surrounded by a<label>, surrounded by a<div>. That<div>has the ID, and not the outermost<div>. That makes sense, as it conforms to how all the other default profile field types are outputted.I've attached an example
Comment #4
johnhanley commentedBrandon,
Profile Checkboxes doesn't do anything to manipulate/override the default profile field output so the exclusion of the ID from the outermost wrapper div for checkboxes and radio buttons must be deliberate.
Thanks for taking the time to investigate and post your findings.
Cheers,
John
Comment #5
akalata commentedI can confirm that the same effect of removing the wrapper IDs can be achieved by using the Form API instead of this module to affect the select type. Using
hook_form_alterto change the field #type via$form['fieldset']['profile_field']['#type'] = 'radios';also removes the wrapper ID.It is possible to get around this using
#prefixand#suffixto create a div wrapper with an ID -- maybe there's a way for this module to get what the ID value of the wrapper would be, and add it in?Comment #6
johnhanley commented@akalata,
I think your suggested solution of adding #prefix and #suffix div wrapper with an ID is a good one. Unfortunately my current work schedule permits me from testing it myself, but if you're able please give it a try and report back. Thanks!
John
Comment #7
dman commentedSounds like a limitation of Drupal6 FAPI that I've seen before. Fieldsets and wrappers don't get an ID when themed, even if given one through Form API.
Not really this modules fault.
I got around it by setting and defining a custom theme_fieldset function in the #theme of the form element. ... in an entirely different project. #prefix & #suffix looked too messy for me. Just FYI.
Comment #8
johnhanley commented@dman,
Thanks for the clarification and vindication re: this issue. :-)
I like your theme function approach better using #prefix & #suffix attributes. Would you care to share a snippet or point me to a project that contains an example?
Cheers,
John
Comment #9
dman commentedSomething like this.
Looks like a lot, but it's just a paste from the core theme function.
Remember to declare the functions in hook_theme if you are going to use this.
Comment #10
oliverpolden commentedAn alternative would be to add a hook_form_element() in your template.php or in a module:
Copy the theme_form_element() function code from here, or from your existing core:
http://api.drupal.org/api/function/theme_form_element/6
Paste it in template.php as yourtheme_form_element() or in a module as yourmodule_form_element().
Then after this:
Add this:
This could be added to the profile checkboxes module, but I agree, it seems to be a problem elsewhere.
Comment #11
EvanDonovan commentedxalen's solution seems the most elegant. Retitling.
There is no patch on this issue, so setting back to "active".
Comment #12
dman commentedIt would be elegant it it wasn't for the fact that theme_fieldset() doesn't use theme_element(), hence why a work-around is needed for them.
It works OK on just theme_checkboxes - which currently deliberately discards the #id (why?)
But I needed a solution that would insert IDs into fieldsets and wrapper divs.
Comment #13
EvanDonovan commentedOk, sorry. Was just trying to clarify the direction moving forward. Retitling accordingly.
Comment #14
dman commentedNah, it's OK. In THIS issue, the checkboxes are all that were asked for, and that's sorta addressed here. The discussion drifted into the general FAPI ID thing. And core FAPI is not going to be fixed from here.
Comment #15
johnhanley commentedClearly, this problem isn't specific to Profile Checkboxes. I think dman's proposed workaround is a good one. I'm going to set the status of this issue as fixed. Thanks!