Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Once one enables Forum module the "Parent" field become hidden in all terms form (forum and non-forum), I think this due to the following code in forum_form_alter function
if ($form_id == 'taxonomy_form_term') {
unset($form['advanced']['parent']);
}
Maybe the function should ask if (isset($form['vid']) && $form['vid']['#value'] == $vid) before disable the parent option.
Comment | File | Size | Author |
---|---|---|---|
#12 | forum_cleanup-214058-10.patch | 1.7 KB | keith.smith |
#9 | forum_cleanup-214058-9.patch | 1.7 KB | cburschka |
#7 | forum_cleanup-214058-7.patch | 1.76 KB | cburschka |
#5 | forum_cleanup-214058-5.patch | 2.62 KB | cburschka |
#1 | forum_cleanup.patch | 2.42 KB | catch |
Comments
Comment #1
catchThis was my fault, introduced with the taxonomy forms cleanup when parents were switched on by default for all vocabularies. Shobaki's entirely correct. I also moved the variable_get to the top of the function which removes an if if and prevents a second one being introduced. Note this makes the patch look bigger than it actually is due to indentation.
Comment #2
catchAlso bumping to critical since this breaks functionality in unexpected ways. Please test!
Comment #3
Emad CreditAttribution: Emad commentedworks perfect, now parent disabled only for forum terms,
thank you for the quick patch
Comment #4
cburschkaFollowup problem: Unsetting the parent field, which after this patch will only happen in the forum vocabulary, may be responsible for a notice in taxonomy.admin.inc:taxonomy_form_term_submit().
If it is, perhaps this patch could try to fix its notice while it's at it - possibly by using something other than unset() - '#type' = 'value'?
Comment #5
cburschkaApplied patch, tested, turns out this does cause the notice.
I'm changing unset() to the following:
This removes the notice without requiring a patch to taxonomy.module, and has the same effect.
Comment #6
Gábor HojtsyWhat about wrapping it all in an if (isset($form['vid']) && $form['vid']['#value'] == $vid) and branch to the two form types from there? Would save us some repeating code, and would cleanup up how we focus our stuff on the proper taxonomy forms.
Comment #7
cburschkaDone.
Incidentally, there is one setting in the "designated forum vocabulary" that is reminiscent of the role settings in the user editing form. Namely, the designated forum vocabulary must always be attached to the forum topic content type, so this checkbox should technically be disabled.
It's probably not worth repeating what was just committed to user.module, as that change has to work around form API quite inelegantly. But if Form API gains support for individually disabled checkboxes in the future, both of these forms could use it.
Comment #8
chx CreditAttribution: chx commentedHiding form elements are best done with slapping an #access FALSE on them.
Comment #9
cburschkaFor sure!
Comment #10
cburschkaI'll be gone for at least a week. Let this be the final version, or someone else will have to take care of it.
Comment #11
Gábor HojtsyLooks good except that we use much more "elseif" then "else if", so I'd use "elseif". This is a minor nitpick I can modify on commit. Otherwise with some more testing this looks good.
Comment #12
keith.smith CreditAttribution: keith.smith commentedI rerolled this to use "elseif" instead of "else if", and to add a period at the end of one of the code comments (and since Arancaytar is afk). (Please no credit on commit for a two-character change.)
Comment #13
keith.smith CreditAttribution: keith.smith commentedSorry, I should have tested this as well, while I was here.
On an *unpatched* copy, I created a new vocabulary and gave it some terms. Noticed that I received a notice regarding "parent" when creating a term, and that the Parent selector did not appear in the Advanced options fieldset for my new, non-forum related vocabulary.
Patched my copy. Created more terms for the same vocabulary, and noted that I did not receive a php notice, and that the Parent select appeared properly. Assigned some terms as parents of other tags, and confirmed that the hierarchy was reproduced properly when listing terms.
Went to the forums vocabulary and confirmed that the Parent select was, indeed, still not present.
So, as far as I can tell based on that, this is fine.
Comment #14
Gábor HojtsyCode looks good, reviews are positive, so committed! Thanks.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.