This topic contains 2 replies, has 2 voices, and was last updated by  devr52 2 weeks, 5 days ago.

  • Author
    Posts
  • #9389

    devr52
    Participant

    When creating a piklist field for a custom taxonomy on a cpt,
    I can set 'scope' => 'post_meta' and provide a field name, and it will save the
    id of the taxonomy term chosen to that custom meta field with the provided name.
    This of course is not the same as using the built-in WP terms table, which allows the taxonomy to be edited in the admin page for the cpt normally.

    To correct this, I change the scope of the piklist field to "taxonomy". Now it saves to the WP terms table, and the built-in WP mechanisms also work. However, what happens to 'field'? If I remove it, it no longer works, but what is it doing with it?

    When the field is set as required and nothing is chosen, it doubles up the error message saying:

    * <Label> is a required field
    * <field name value> is a required field

    This is ugly and broken.

  • #9390

    Steve
    Keymaster

    This is not broken. You just didn’t take the time to go through the code.

    If you take a look in the Piklist Demos you would see that the when the scope is set to taxonomy, we use piklist_demo_type as the field, because that is the taxonomy we want to save against.
    https://github.com/piklist/piklist/blob/develop/add-ons/piklist-demos/parts/meta-boxes/field-taxonomies.php#L22-L23

    I also updated the docs to explain this:
    https://docs.piklist.com/fields/field-parameters/#field

  • #9396

    devr52
    Participant

    That is what my field is set to–the taxonomy type.
    It still doubles up the error message, so that is still an issue–any ideas?

You must be logged in to reply to this topic.