When adding a custom field to a MailChimp Subscriber List the module causes an error because the options set by MailChimp do not include a size for the field and the default textfield is used which defines a size. Below is an abbreviated output of the error:

Error messageNotice: Undefined property: stdClass::$size in mailchimp_insert_drupal_form_tag() (line 1162 of modules/contrib/mailchimp/mailchimp.module).
mailchimp_insert_drupal_form_tag(Object) (Line: 124)
Drupal\mailchimp_signup\Form\MailchimpSignupPageForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 512)
Drupal\Core\Form\FormBuilder->retrieveForm('mailchimp_signup_subscribe_block_contact_the_gatesworth_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('mailchimp_signup_subscribe_block_contact_the_gatesworth_form', Object) (Line: 212)
Drupal\Core\Form\FormBuilder->getForm(Object) (Line: 35)

CommentFileSizeAuthor
#24 2788129-custom-field-undefine-property-23.patch871 bytesHenry Tran
#20 combined-telephone-and-size-fix.2788129.patch897 bytesspiderman
#16 mailchimp-7x4xdev-2788129-16.patch493 bytesbasvredeling
#14 mailchimp-undefined-property-size-D7.patch492 bytesFunkwarrior
#10 mailchimp-undefined-property-size-2788129-10.patch575 bytesjoelstein
#6 2788129_MailchimpSizeAssumption.patch574 bytesMaskOta
#5 2788129_MailchimpSizeAssumption.patch647 bytesMaskOta
#2 mailchimp-telephone-form-field-error-2788129-2.patch447 bytesDaniel Korte
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Daniel Korte created an issue. See original summary.

Daniel Korte’s picture

The attached patch fixes the issue by giving the phone field it's own case in the switch statement and with the added benefit of using the HTML5 tel form field.

Daniel Korte’s picture

Status: Active » Needs review
Daniel Korte’s picture

Issue summary: View changes
MaskOta’s picture

This is not a problem only for phone fields but any custom field.

The module assumes the size was set. I think we should do a check if the size was set and if it was not we should apply a default value. I put in size = 25 because i think this is the default for other fields.

Daniel Korte’s picture

I think the two patches should be combined so that the telephone HTML5 input type is still used for telephone fields. Thoughts?

MaskOta’s picture

I think it would require to open a separate issue.

MaskOta’s picture

Title: Custom Field Causes size Error » Custom Field Causes Undefined property Error
joelstein’s picture

I'm seeing the same thing on Drupal 7. Here's a D7 patch.

Greg Boggs’s picture

Version: 8.x-1.2 » 8.x-1.x-dev
echoz’s picture

The D7 patch, in #10 also works to get rid of the notice filling up the logs when viewing the mailchimp form on the site. Can this also get backported to D7?

jesss’s picture

The D7 patch in #10 is working for me as well. +1 for the backport.

Funkwarrior’s picture

jesss’s picture

The D7 patch #14 works for me.

basvredeling’s picture

dietr_ch’s picture

Patch in #6 still works with 8.x-1.2.

basvredeling’s picture

The patch from #16 is no longer necessary. Current dev code already includes this solution.

Greg Boggs’s picture

Status: Reviewed & tested by the community » Needs work

It looks like the 2 d8 patches need work to be combined as the thread got reused by the D7 patch.

spiderman’s picture

I've rolled a combined d8 patch including the telephone fix and the size fix. Thanks to MaskOta and Daniel Korte for their efforts :)

DrIPA’s picture

#20 works for me, thanks!

gcb’s picture

Component: Lists » General
Assigned: Unassigned » aprice42
Henry Tran’s picture

I've re rolled to mailchimp 2.x, upload again

  • xenophyle committed e88cfd6a on 2.x
    Issue #2788129 by MaskOta, Daniel Korte, basvredeling, Henry Tran,...
xenophyle’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.