Craft CMS Asked by Ed Hebert on March 15, 2021
I’m working on a front-end entry form with custom text input fields. From the Entry Form knowledgebase docs, I read "Any custom field handles must be provided in a fields[] array like body is above." On that page their example ‘body’ field is a textarea field, and when I use this with my own textarea fields it works fine. However I’m having trouble formatting that same logic to make a simple plaintext input field work properly.
My current (non-working) code is:
<label for="contactName">Contact Name</label>
{{ input('text', 'contactName', entry.contactName, {
id: 'contactName',
name: 'fields[contactName]'
}) }}
No errors are being thrown when I submit the form, but the values from the plaintext input area are not being saved. What’s the proper way to format such that the input values are saved properly?
The second parameter of the input
function is the name attribute, which you currently have as contactName
. Assigning it in the options like you have does not override the initial supplied parameter. Try this:
{{ input('text', 'fields[contactName]', entry.contactName, {
id: 'contactName'
}) }}
Correct answer by ajamesm on March 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP