Bug #23522 See Comments

channel:form isn’t saving related field.

Version: 4.1.1 Reporter: Bill the Grue

channel:form doesn’t seem to save a related entry.

To replicate:

  1. create one channel named “courses” and populate it with 2 or 3 courses (math1, math 2, math 3, for example)
  2. in the channel named “courses” please create a simple field named “instructor” and have a select-drop-down list (don’t relate this field)
  3. create another channel named “enrollment” and relate the course to channel to the course channel.
  4. try the code below:
{exp:channel:form 
                         channel="enrollment"
                         class=""
                         id=""
                         return="/learn/enrollment"
                         }

<select name="courses[]">
                {options:courses}
                        <option value="{option_value}"{selected}>{option_name}</option>
                {/options:courses}
</select>




{options:instructor}
           <input class="form-check-input" type="radio" name="instructor" value="{option_value}" id="{option_value}"> 
           <label class="form-check-label" for="{option_value}">{option_name}</label> 
{/options:instructor}

{/exp:channel:form}

In my case, I note the “instructor” field saves, but not the “courses” in the enrollment channel.

Thank you for your help!

  • Hey Bill!

    That template code isn’t valid for a relationship field, not sure where you pulled that from. If it’s in the docs please let me know and I’ll update it.

    To use the {options:relationship_field} syntax, your form input needs to be my_field_name[data][], so it should be courses[data][], etc.

    Derek Jones
    13th March, 2018 at 12:51pm

You must be signed in to comment on a bug report.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases