1

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?

1 Answer 1

2

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'
}) }}
1
  • Gotcha! That makes perfect sense. Thanks for talking me through it. Works perfectly now. Much appreciated.
    – Ed Hebert
    Feb 25, 2021 at 14:01

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.