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)

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

Title: Phone Field Type Causes Error » Custom Field Causes size Error
Issue summary: View changes
StatusFileSize
new647 bytes

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.

MaskOta’s picture

StatusFileSize
new574 bytes

I uploaded the wrong patch...

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

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new575 bytes

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

StatusFileSize
new492 bytes

remove post...

jesss’s picture

The D7 patch #14 works for me.

basvredeling’s picture

StatusFileSize
new493 bytes

new patch because #14 didn't apply to latest 7.x-4.x-dev anymore

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

StatusFileSize
new897 bytes

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

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.