Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: mcVar #94

Open
zacharybrady opened this issue Nov 1, 2017 · 1 comment
Open

Undefined index: mcVar #94

zacharybrady opened this issue Nov 1, 2017 · 1 comment

Comments

@zacharybrady
Copy link

I am using the most recent version of Formerly. I do not have Mailchimp set up.

When trying to add a new field to a form I get the error "Undefined index: mcVar" related to line 135 in Formerly_FormsController.php $question->mcVar = $postedQuestion['mcVar'];

This does not happen when initially creating a new form.

As a temporary work around I am changing that line to: $question->mcVar = (isset($postedQuestion->mcVar) ? $postedQuestion['mcVar'] : null);

@tom-c
Copy link

tom-c commented Feb 6, 2018

This is more complex than it seems - if you apply the above you will lose your existing Mailchimp Merge Tags info on save.

From what I can tell the 'mcVar' field needs to be present in the matrix block added via 'Add question' button. This in turn is via the 'question template' that's set in the javascript which comes from the 'forms/_edit.html' macros.

I've tweaked the code in there so that the 'Mailchimp Merge Tag' is no longer within the {% if question %} conditional and it seems all is well.

Line 41 onwards:

				{% if question %}
				<div class="field" id="questions-15-name-field">
					<div class="heading">
						<label for="questions-15-name">Email Tag
						</label>
					</div>
					<div class="input ltr">
						{{'{' ~ (question ?  question.handle | replace({(emailPrefix) : ''})) ~ '}'}}
					</div>
				</div>
				{% endif %}

			{{ forms.textField({
				label: 'Mailchimp Merge Tag',
				id: "questions-#{id}-mcVar",
				name: "questions[#{id}][mcVar]",
				value: question ? question.mcVar,
				errors: question ? question.getErrors('mcVar'),
				instructions: "*required if this form is submitting to a mailchimp list. Must match Mailchimp merge tag exactly.",
				}) }}

Hope that helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants