1

I would like to give users the option to "Save as Draft" or "Publish" at the end of a Channel Forms entry.

Is there a way to attach a status to a button? Has anyone done something like this?

1 Answer 1

0

Submit buttons can have a name and value, too. And if you use actual <button> elements, the value can be different from what's displayed on the button (unlike using <input type="button" />).

Take this simplified example (just using a regular old form):

<form action="" method="post">
    <input type="text" name="title" />
    <button type="submit" name="status" value="draft">Save as draft</button>
    <button type="submit" name="status" value="open">Publish</button>
</form>

If you click the 'Save as draft' button, the form will send along status=draft. If you click the 'Publish' button, the form will send status=open instead. If you hit return in the text field (submitting the form), the value of the first submit-button will be posted.

This is true for any web form (or at least apache/php), so it should work for EE's Channel Form, too.

Alternatively, you could just use a single save-button and add a checkbox to the form to enable 'save as draft', and apply the status to that field, ie.

<label>
    <input type="checkbox" name="status" value="draft">
    save as draft
</label>

...and status=draft will be posted if the checkbox is ticked.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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