1

I'm working on a front-end entryform and wondering which field types are supported with the default controller ({{ actionInput('entries/save-entry') }}). Title and plain text fields are working but looks like URL fields for example doesn't.

In the backend I'll see there is an hidden field with type for the URL but adding that also not updating the field value. I tried this:

 <label for="website">Website</label>
                    <input type="hidden" name="fields[website][type]" value="url">
                    {{ input('text', 'fields[website][value]', entry.website ?? null, {
                        id: 'website',
                    }) }}
                    {{ _self.errorList(entry.getErrors('website')) }}

Only use fields[website] with or without fields[website][type] also doen't work.

2 Answers 2

1

From my experience I think you can work on all kinds of elements, you just have to know how to use them, I have done a webpage that contain most of them look it at this url : https://beta.sfd-yemen.org/project-fund for the url, you do not need to add the hidden field, this work just fine:

<div class="col-sm-6">
                                <div class="mb-3">
                                    <label for="projectName" class="form-label">Website:<br/>
                                    </label>
                                    <input type="text" name="fields[urlField][value]" value="{{ entry.urlField }}" class="form-control required"
                                           id="projectName" placeholder="Enter Website">
                                    {{ _self.errorList(entry.getErrors('urlField')) }}
                                </div>
                            </div>

*info : I am using (Guest Entries https://github.com/craftcms/guest-entries) plugin to save the entry.

1

I found out this had to do with the conditional field settings (in the field layout settings). If fields for the backend has certain conditions this has also influence on the front-end. Fields that are hidden by a condition can't be updated via the front-end. Sow nothing wrong in my code mentioned. After remove the conditions the fields are saving the normal way.

Your Answer

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

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