How to hide field for new entry, but show it when updating entry?

By: Alex Barron | Asked: 06/20/2022
ForumsCategory: How-toHow to hide field for new entry, but show it when updating entry?
Alex BarronAlex Barron asked 2 years ago
I have a field "Goal Status" which is automatically set to "active" when a new "Goal" (custom post type) is created from filling in the form. Therefore, I don't want to show that field when creating a new entry. However, when the user wants to edit the entry on the front end, I want to show that field so that they can set it to "Completed" or "Archived". I don't see anything in the interface to allow this. The Conditional Logic option for the field doesn't do what I need.   I have already tried creating 2 forms: 1 for new entry and for 1 updating existing entries. However, due to only being able to link a View to 1 form, the fields are not autopopulated when editing an entry (because I linked the View to the New Entry form).   Thanks in advance!
1 Answers
Victor Font answered 2 years ago
You can use conditionals triggered by hidden fields to do what you want, but it's hard to say for certain without fully understanding your design. You can also display only specified fields on your form when you first load it on the page. Don't include the fields that store the status. See this knowledge base article for details:
Alex BarronAlex Barron replied 2 years ago

<p><p>Thanks Victor.<br />1. Being able to specify fields to include via the shortcode is handy, but this solution would still mean i would have 2 edit pages, correct? 1 with the shortcode that includes the fields for a new entry, and another with the other shortcode including the fields for updating an entry. Is that how you could see it working?</p><p>2. Why should I avoid using my Goal Status field?</p><p>3. What would you need to know in order to fully understand my design? I will be as clear as possible.</p></p>

Victor Font replied 2 years ago

Yes, the alternative is to hide what you don't want shown with CSS or a combination of CSS and jQuery to hide/show elements on the screen whether in entry or edit mode. This could be a lot of work depending on your design and how dynamic your requirements are.

Joe Semones replied 3 months ago

<p>Hi Victor, I found this question while searching for a similar answer. I know it's dated, but perhaps the question still applies. <span style="font-size: 14.000001px;">Is it possible to hide a field on a form but show it on a view of the same table?</span><br />I have a form which has 2500 old records to go with new data users could be entering. The users may wish to comment or recommend updates on the historical records. The table is an In Memory table of people who've died over the years, and our members could have information which corrects some of the data we've captured. <br /><br />What I'd like to do is add a field to the table which would capture anything the user wished to submit regarding the historical record, but I don't want to show it when users are creating new records, so it would need to be hidden in those circumstances, but if they're recommending changes or additions to a record, I'd like to show and allow editing of only the comment field only. I don't want to give them the permission to edit the other fields directly.</p>

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community