1

I have created a page where user creates an entry but its status is disabled. This page then redirects to a page where the user gets to see a preview of his entry. On this preview page there are two publish button when clicked the status of the entry has to be enabled. The code I have used is:

<form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="entries/saveEntry">
    <input type="hidden" name="redirect" value="/user/thanks/{{slug}}">
    <input type="hidden" name="sectionId" value="4">
    <input type="hidden" name="entryId" value="{{entry.id}}">
    <input type="hidden" name="enabled" value="1">
    <button type="submit" class="btn-save">Publish</button>
</form>

But after submitting the form it reloads the same page. I checked the craft.log, it has the following errors:

2017/06/08 13:17:53 [warning] [application] Craft\ContentModel->dailyPlan failed validation: Daily Plans cannot be blank. ( a matrix field )
2017/06/08 13:17:53 [warning] [application] Craft\ContentModel->banner failed validation: Banner cannot be blank. ( an asset field )
2017/06/08 13:17:53 [warning] [application] Craft\ContentModel->Included failed validation: Included cannot be blank. ( a table field )
2017/06/08 13:17:53 [warning] [application] Craft\ContentModel->Excluded failed validation: Excluded cannot be blank. ( a table field )

Can't I change the status of entry simply with the above form? Do I have to load all the required fields with its value? Well I don't want to do that as it would take lot of extra lines of code and also the execution time will be longer, as there are two publish button on the page.

1

I think so, if they are required fields. You'd just add them as hidden fields and there wouldn't be any additional database queries because it's already fetched the entry anyway.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.