Opened 6 months ago

Last modified 3 months ago

#22700 new defect (bug)

Walker_Category_Checklist should sometimes set the value as the term name

Reported by: simonwheatley Owned by:
Priority: normal Milestone: Awaiting Review
Component: Administration Version: 3.0
Severity: normal Keywords: has-patch dev-feedback
Cc:

Description

The Walker_Category_Checklist class has been partially adapted to work with taxonomies other than category, but it does not seem to cope with non-hierachical taxonomies.

For non-hierachical taxonomies, the HTML form elements (checkboxes, radios, dropdowns, whatever) need to set the term name as the value, not the ID… otherwise WordPress will cast the ID to a string and create a new term with that string as a name.

To see the problem:

  • Use Walker_Category_Checklist to create a checkbox in a metabox on the post edit screen for a non-hierarchical taxonomy
  • Add some terms to the taxonomy
  • Check the box for the taxonomy and update the post
  • Watch a new term appear with its name set to the ID of the term you checked

Attachments (1)

22700-sw.diff (1.8 KB) - added by simonwheatley 6 months ago.
Set form element value to name if taxonomy is non-hierarchical

Download all attachments as: .zip

Change History (6)

Set form element value to name if taxonomy is non-hierarchical

  • Component changed from General to Template
  • Keywords has-patch dev-feedback added

The diff adds a check to see if the taxonomy is hierarchical, and sets the value appropriately.

  • Version changed from trunk to 3.0

This may be a duplicate of another ticket.

Regardless, not a regression. Pulling it back a few versions. I imagine this was done in 3.0 (a guess, admittedly).

I will bow to your superior Trac knowledge! I did search for a few terms to see if the issue had previously been supported, but couldn't see anything obvious…

Tested patch, still applies. The undesirable behaviour (terms being created with names equivalent to the term IDs) still occurs.

  • Component changed from Template to Administration
Note: See TracTickets for help on using tickets.