2

I have an entry form (in a local v3.5.13.1 dev context) configured to update existing entries in a particular section. On load, it’s reflecting existing data (input via the Craft control panel) perfectly well, including Assets and Matrix field content.

But when I'm logged in as a Super Admin and I submit changes, it will receive updates to the entry Title field but not to any custom fields.

No errors are being reported and it redirects to the desired page.

At present, I have stripped it right back to the Title field and a single Plain Text custom field but no joy. Here is my form code:

{% set entry = entry ?? create('craft\\elements\\Entry') %}
{% set redirectUrl = "partners/#{entry.id}" %}
{% set sectionId = entry.sectionId %}

<form method="post" accept-charset="UTF-8">
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ redirectInput(redirectUrl) }}
    {{ hiddenInput('sectionId', '5') }}
    {{ hiddenInput('enabled', '1') }}
    {{ hiddenInput('entryId', entry.id) }}
    {{ hiddenInput('entryVariable', 'badEntry'|hash) }}

    {% macro errorList(errors) %}
        {% if errors %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    {% endmacro %}
          
    <p>
        <label class="field-below">
            <span class="field-label"><strong>Organisation name</strong></span>
            {{ input('text', 'title', entry.title, {
                required: true,
                class: entry.hasErrors('title') ? 'text error' : 'text'
            }) }}
            {{ _self.errorList(entry.getErrors('title')) }}
        </label> 
    </p>

    <p>
        <label class="field-below">
            <span class="field-label">
                <strong>Headline:</strong>
                <span class="line-ib">Optional, 10 words or fewer recommended</span>
            </span> 
            {{ input('text', 'headline', entry.headline, {
                required: true,
                class: entry.hasErrors('headline') ? 'text error' : 'text'
            }) }}
            {{ _self.errorList(entry.getErrors('headline')) }}
        </label> 
    </p>

    <p class="field-submit">
        <input type="submit" class="btn" value="Update page">
    </p>
</form>

No updates to the Headline field get saved. Updates to the Title field do. Where can I be going wrong?

3

You need to pass your custom fields in a fields array, try:

{{ input('text', 'fields[headline]', entry.headline, {
    required: true,
    class: entry.hasErrors('headline') ? 'text error' : 'text'
}) }}

See example here - https://craftcms.com/knowledge-base/entry-form

3
  • 1
    Thanks so much Oli, that's what I needed. It's my first time making an Entry Form. The Entry Form doc really ought to make this point but it doesn't! Nov 10 '20 at 15:03
  • 1
    Just talking with Matt about it so we make it more obvious :) Glad you're sorted!
    – Oli
    Nov 10 '20 at 15:07
  • Ironically all my most complex fields already had fields[handle] going on, but the simplest ones didn't because they were derived from the root doc! Nov 10 '20 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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