putyourlightson / craft-campaign

Send and manage email campaigns, contacts and mailing lists in Craft CMS.
https://putyourlightson.com/plugins/campaign
Other
64 stars 24 forks source link

Certain custom fields not saving as contact preferences. #436

Closed D3VM4TT closed 10 months ago

D3VM4TT commented 10 months ago

Hi, we are currently using the Campaign Plugin for one of our clients & we have noticed some of the custom fields are not saving.

Please provide a clear and concise description of what the bug is, including: - Steps to reproduce the issue. We currently have a Job Notification sign up form that is posting to campaign/forms/subscribe. Most of the fields are saving and being reflected in the contact preferences, however there are currently two fields that are not being saved.

One of the fields being the Job Sectors field. This is a Multi-select field with the handle of jobSectors. Currently we are rendering the checkbox fields in the form as per below:

<div class="form-checkbox">
        <label>
            <span>Administration</span>
            <input class="form-field " type="checkbox" name="field[jobSectors][]" value="administration" data-label="Administration">
        </label>
    </div>
<div class="form-checkbox">
        <label>
            <span>Advice and information</span>
            <input class="form-field " type="checkbox" name="field[jobSectors][]" value="adviceAndInformation" data-label="Advice and information">
        </label>
    </div>

This same field is added to the Campaign Contacts Preferences.

We have several other Multi-Select fields rendered in the same way in Sign Up form and the are all saving as expected - however the the selected jobSectors are not being saved to the contacts preferences for some reason.

I have checked the payload being sent to campaign/forms/subscribe & I can confirm the jobSectors fields are included in the form-data as per below:

feld[jobSectors][]: administration
field[jobSectors][]: adviceAndInformation
field[jobSectors][]: advocacy
field[jobSectors][]: artsCultureAndHeritage
field[jobSectors][]: campaigningAndFundraisin  

Front end form with Job Sectors Screenshot_20231113_115325

Job Sectors field added to contact preferences Screenshot_20231113_115402

jobSectors field in Craft Screenshot_20231113_115439

jobSectors field in contact prefences Screenshot_20231113_115510

        "putyourlightson/craft-campaign": "2.9.4",
        "craftcms/cms": "4.5.5",
bencroker commented 10 months ago

Are you sure that the field name is correct? I would think that it should be fields[jobSectors][], so fields instead of field.

D3VM4TT commented 10 months ago

So right. Cant believe I missed that. Thanks @bencroker