As seen in taxonomy.module, _taxonomy_term_select returns a form element with a #type of 'select' and a #theme value of 'taxonomy_term_select'. However, despite my best efforts, I have found it impossible to theme the taxonomy term selection drop down list without retheming theme_select.

After a bit of debugging, I discovered theme('taxonomy_term_select', $element) is called, but its output is ignored and theme('select') is used instead, even if the default theme_taxonomy_term_select function (which simply calls theme('select', $element)) is overridden.

I have a feeling this may be a bug in the new Form API's form_render function, but I could be wrong. Let me know if more information is needed to resolve this bug, I would love to see it fixed for the 4.7 release.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

speakout_tom’s picture

Status: Active » Needs review
FileSize
571 bytes

Fixed using 'markup' instead of 'select' for the #type attribute of the element returned by _taxonomy_term_select. Patch attached.

adrian’s picture

Status: Needs review » Needs work

It might look correct with that patch, but there's no way we could validate against it.

How are you trying to theme it ?

Have you tried using form_alter and using the '#theme' property ?

chx’s picture

Adrian, the problem is something like that #theme callbacks render children but the actual element is still rendered by the element renderer. What we need here is that if the children are empty but there is content then we should not call the element renderer.

chx’s picture

FileSize
671 bytes

Something like this...

adrian’s picture

I think chx' solution is correct for this.

chx’s picture

Component: taxonomy.module » forms system
Status: Needs work » Reviewed & tested by the community
FileSize
1.64 KB
Gerhard Killesreiter’s picture

Status: Reviewed & tested by the community » Fixed

applied

Zen’s picture

Version: 4.7.0-rc3 » x.y.z
Priority: Normal » Critical
Status: Fixed » Active

node edit form: Associated terms are no longer being preselected.

-K

chx’s picture

Assigned: Unassigned » chx
Status: Active » Reviewed & tested by the community
FileSize
940 bytes

Of course not when #value is overwritten! I forgot the last change here.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Confirmed existence of problem, and chx's patch does indeed fix it.

I then went through and did my "click around to every bloody form I can think of" test -- created new account, logged in, messed w/ taxonomy, access control, etc. -- all looks good! RTBC.

webchick’s picture

Status: Fixed » Reviewed & tested by the community

ahem. :P

Zen’s picture

Status: Reviewed & tested by the community » Needs work

Patch fixes issue. Shouldn't the comment be moved up as well?

Setting to Comment needs work.

Thanks,
-K

dopry’s picture

Status: Needs work » Reviewed & tested by the community

No the comment belongs to another code block, and shouldn't be moved.

killes@www.drop.org’s picture

applied to 4.7 branch

Zen’s picture

FileSize
900 bytes

And the comment moved to the correct location.

-K

killes@www.drop.org’s picture

applied to 4.7 branch

dmitrig01’s picture

Status: Reviewed & tested by the community » Fixed
dww’s picture

for the interested reader, drumm also applied this to head as revision 1.114. so yes, it truly is fixed on both branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)