1

I'm trying to update a drop down field type on an entry using a front end form. However, the input is a hidden field (not a select)

This is the form code I have so far:

<form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="entries/saveEntry">
    <input type="hidden" name="redirect" value="questions/{{ selectedSession }}">
    <input type="hidden" name="enabled" value="1">
    <input type="hidden" name="sectionId" value="{{ question.sectionId }}">
    <input type="hidden" name="entryId" value="{{ question.id }}">
    <input type="hidden" name="fields[questionStatus][]" value="answered">
    <input type="submit" value="submit">
</form>

Where questionStatus is my dropdown field handle. Any insight would be appreciated Thanks

Update

I have ensured that the account's user type has the necessary permissions to perform this operation

3

I think you just need to get rid of the [] on the field name, so your field becomes:

<input type="hidden" name="fields[questionStatus]" value="answered">

As long as the value is the same as the value in the dropdown, it should change.

I think the issue you are getting is because you are telling the field that its value is an array, where you just need to pass the actual value as a string and Craft will figure out the rest :)

  • Thanks for your reply, but unfortunately that didn't solve it. In fact, that was what I'd first tried as it made the most sense. The added [] was just a (very bad) shot in the dark. When viewing the admin at the same time, I get a "couldn't save entry" popup notification, which I guess is expected – user4041 Sep 3 '15 at 8:42
  • Ok, I managed to figure out the error by looping through all the errors for the entry. There were some required fields that needed to be set. However, I thought Craft would just maintain them as they considering this is an update not an insert.... – user4041 Sep 3 '15 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy