Problem: I have an edit post Form that allows Users to update a custom field value in a post. I would like to include multiple submit buttons in the Form, and depending on which Submit button is clicked I would like to change the custom field to a different value.
Solution: You can achieve this with 3 Forms that edit the post. Here's the general idea:
- Create an edit post Form for this post type, and auto-generate the Form contents. Delete the post title input, the post content input, and any taxonomy inputs from the Form. Delete all custom field inputs except for the select field. Set the value of the custom field to match the value corresponding to "Todo". You can find this in the custom field editor screen.
- Wrap the select field shortcode in a hidden div like this:
<div style="display:none;"> [cred_field field='your-field-slug' value='12345' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap'] </div>
- Change the value of the "Submit" button shortcode to be "Todo".
- Place this Form in the template for the post you want to edit.
- Now all that should be visible in this Form is the "Todo" button. When the User submits this Form, the select field will be set with the correct status. None of the other post information will be changed.
- Repeat the process for the two other Forms.
- Once your buttons are all visible, use conditional HTML to show and hide the Forms as needed depending on the post's current custom field value. In other words, hide the "Todo" button when the custom field value is already "Todo", etc.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 4 replies, has 2 voices.
Last updated by 6 years, 2 months ago.
Assisted by: Christian Cox.