Tags

Create Entry

{{ guest-entries:create collection="articles" }}
<h2>Create article</h2>
 
<input type="text" name="title">
<textarea name="content"></textarea>
 
<button type="submit">Create</button>
{{ /guest-entries:create }}
{{ guest-entries:create collection="articles" }}
<h2>Create article</h2>
 
<input type="text" name="title">
<textarea name="content"></textarea>
 
<button type="submit">Create</button>
{{ /guest-entries:create }}

Update Entry

{{ guest-entries:update collection="articles" id="article-id" }}
<h2>Edit article</h2>
 
<input type="text" name="title" value="{{ title }}">
<textarea name="content">{{ content }}</textarea>
 
<button type="submit">Update</button>
{{ /guest-entries:update }}
{{ guest-entries:update collection="articles" id="article-id" }}
<h2>Edit article</h2>
 
<input type="text" name="title" value="{{ title }}">
<textarea name="content">{{ content }}</textarea>
 
<button type="submit">Update</button>
{{ /guest-entries:update }}

Delete Entry

{{ guest-entries:delete collection="articles" id="article-id" }}
<h2>Delete article</h2>
<p>Are you 100% sure you want to get rid of this article? It'll be gone forever. Which if you didn't know - is a very long time!</p>
 
<button type="submit">DELETE</button>
{{ /guest-entries:delete }}
{{ guest-entries:delete collection="articles" id="article-id" }}
<h2>Delete article</h2>
<p>Are you 100% sure you want to get rid of this article? It'll be gone forever. Which if you didn't know - is a very long time!</p>
 
<button type="submit">DELETE</button>
{{ /guest-entries:delete }}

Parameters

When using any of the guest-entries tags, there's a few parameters available to you:

collection required

Every tag will require you to pass in the collection parameter, which should be the handle of the collection you want to deal with.

id sometimes required

Both the update and delete tags require you to pass in the ID of the entry you want to work with.

redirect

You may specify a URL to redirect the user to once the Guest Entry form has been submitted.

error_redirect

You may specify a URL to redirect the user to once the Guest Entry form has been submitted unsuccessfully - commonly due to a validation error.

request

You may specify a Laravel Form Request to be used for validation of the form. You can pass in simply the name of the class or the FQNS (fully qualified namespace) - eg. ArticleStoreRequest vs App\Http\Requests\ArticleStoreRequest

Special Inputs

There's a few 'special' input fields that you can take advantage of:

slug

Pretty self-explanatory. Allows you to provide a slug for the created entry. When not provided, a slugified version of the title is used.

date

When using a dated collection, a date will be allowed. When not provided, the current date is used.

published

Pretty self-explanatory. Allows you to control the publish state of the created entry. You should provide either a 1 or true to publish an entry.

When not provided, the entry will be set to unpublished.

Variables

If you're using the update/delete forms provided by Guest Entries, you will be able to use any of your entries data, in case you wish to fill value attributes on the input fields.

{{ guest-entries:update collection="articles" id="article-id" }}
<h2>Edit article: {{ title }}</h2>
<p>Last updated: {{ updated_at }}</p>
 
...
{{ /guest-entries:update }}
{{ guest-entries:update collection="articles" id="article-id" }}
<h2>Edit article: {{ title }}</h2>
<p>Last updated: {{ updated_at }}</p>
 
...
{{ /guest-entries:update }}

Errors

If you'd like to show any errors after a user has submitted the Guest Entries form, you can use the {{ guest-entries:errors }} tag, like shown below:

{{ guest-entries:errors }}
<li>{{ value }}</li>
{{ /guest-entries:errors }}
{{ guest-entries:errors }}
<li>{{ value }}</li>
{{ /guest-entries:errors }}

Success

If you'd like to show a success message after a user has submitted the Guest Entries form, you can use the {{ guest-entries:success }} tag, like shown below:

{{ if {guest-entries:success} }}
Well done buddy!
{{ /if }}
{{ if {guest-entries:success} }}
Well done buddy!
{{ /if }}

Using with Blade

You can still use the tags provided by Guest Entries in Blade. However, they'll work slightly differently. Instead of Guest Entries constructing the HTML of the <form> for you, you need to construct the HTML yourself.

Thankfully, it's an easy process:

@php
$form = Statamic::tag('guest-entries:update')->params([
'collection' => 'articles',
'id' => 'id-of-entry',
])->fetch();
@endphp
 
<form {!! $form['attrs_html'] !!}>
{!! $form['params_html'] !!}
<input type="text" name="description" />
<button>Update article</button>
</form>
@php
$form = Statamic::tag('guest-entries:update')->params([
'collection' => 'articles',
'id' => 'id-of-entry',
])->fetch();
@endphp
 
<form {!! $form['attrs_html'] !!}>
{!! $form['params_html'] !!}
<input type="text" name="description" />
<button>Update article</button>
</form>

The above example uses the {{ guest-entries:update }} form. You simply use the {!! $form['attrs_html'] !!} in the <form> tag (this adds the action and method attributes). Then, somewhere inside the form, add the hidden parameters with {!! $form['params_html'] !!}.

Make sure to pass in any required parameters in the ->params([]) array.