I have a channel form that is trying to create a new entry in a channel. However, I keep getting
The form you submitted contained the following errors
status: This field is required.
In my form, I have a hidden variable names “status” set to “open”. I don’t want to have the user select the status using a dropdown select.
I know that if I go in to the settings for that channel and select a status under the “Channel Form” section, the error goes away (on a side note, even if I choose a default variable of “Open” in the channel defaults and set this to “Use channel defaults”, I still get an error. May be a bug).
However, I would like to know how to set statuses within my forms so I can decide what status to give the new entry based on some template variables.
Here is a simplified form:
{exp:channel:form channel="reporting_questions" include_assets="no" include_jquery="no" return="reporting/settings"}
<input type="hidden" name="url_title" class="url_title" value="questions_{logged_in_member_id}">
<input type="hidden" name="title" value="Test title">
<input type="hidden" name="status" id="status" value="open">
{/exp:channel:form}
Thanks, Steve
Ahh. I should have read more on the forums. My issue is related to this post - (https://ellislab.com/forums/viewthread/248641/ - “Using form tags within channel tags”). If you are in a channel tag, the “status” variable will not be set correctly (even if in a “no_results” section). However, this leads to another problem. I am using the same form to create new entries and edit existing ones. Using the channel:forms tag, I can’t find a way to do both.
For a new entry, I need to leave “url_title” and “entry_id” empty. However, one of them needs to be included to pull an existing entry to edit. But, if I put one of them in the channel:form tag and the entry doesn’t exist, it complains about not having a valid entry.
So, any ideas? Is it not possible to use the same channel:form tag to either edit or create an entry?
Thanks!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.