We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Relationship selection not saving in Channel Form EE3 (Solved)

Development and Programming

CreativelinkUK's avatar
CreativelinkUK
16 posts
7 years ago
CreativelinkUK's avatar CreativelinkUK

I’m having trouble saving relationship data within the Channel Form. The correct related entries appear on the page, however on submitting the form, any chosen related entries are not saved. Checking the new entry in the back end shows nothing selected in the relationship field.

Can anyone advise me on what I’m doing wrong or how I can fix this?

Part of my code:

Teams that play here: 
{options:sports_teams}
     <input type="checkbox" name="sports_teams[]" value="{option_value}"> {option_name}

{/options:sports_teams}

I based the code above on this sample from the official documentation:

{options:my_field_name}
     <input type="checkbox" name="my_field_name[]" value="{option_value}" {checked}>  {option_name}</br>
{/options:my_field_name}

If I set the relationship field to required I get these error messages when submitting:

The form you submitted contained the following errors

Sports teams: This field is required.
sports_teams: This field is required.
       
CreativelinkUK's avatar
CreativelinkUK
16 posts
7 years ago
CreativelinkUK's avatar CreativelinkUK

I had no choice but to upgrade the website from EE3 to EE4 as EllisLab stopped selling EE3 licenses. Once upgraded I was able to fix this issue by using the following code (I don’t know if this works in EE3):

{custom_fields}
   {if relationships}
      {if allow_multiple}
         {options:sports_teams}
            <input type="checkbox" name="{field_name}[data][]" value="{option_value}"{checked}> {option_name}
         {/options:sports_teams}
      {/if}
   {/if}
{/custom_fields}
       
bobural's avatar
bobural
20 posts
7 years ago
bobural's avatar bobural

just wanted to say thank you. your example helped me with an similar issue.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.