Support

Account

Home Forums Backend Issues (wp-admin) Debugging a custom field type

Unread

Debugging a custom field type

  • Hi there –

    I’ve created my own custom field type which uses a multi-select menu to display the wordpress tags in the menu. I’ve hooked it up to select2 which allows me to type into the box and then select the tags that I want to add to the post.

    I’ve got it all working where when i add tags to my field and click update on the post, it will add the tags to “Tag” section of wordpress. That works great.

    Except I’ve run into one problem where if i remove all of the tags from my field, click update, it is not removing all of the tags from the post. Instead, it is is ignoring this process like nothing is happening.

    What i figured out was I needed to be submitting an empty option value in the select in order for it to update and remove all of the wordpress tags from the post.

    I was trying different things in the different functions from the field type template and i created a little hack for this. I added some javascript that will inject an empty option value if the field is empty. I’d rather not to do it this way.

    If you have some suggestion which function I should use to check if the values are empty and if they are, to remove the tags from the post.

    I think where I am running into trouble is I’m not sure how to debug my field type. I want to echo or somehow output the values being submitted, but I was not able to get that to work outside of the render field function.

    Any thoughts?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.