Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What is the best approach to re-order the fields on the signup block? I would prefer the email to come after the First/Last name fields.
Comments
Comment #2
Greg BoggsUnfortunately, the MailChimp dashboard doesn't give you a way to move the email address on the MailChimp side. So, there are a few options. Starting with the fastest to the most complex:
1. Move it with jquery.
2. Write a hook_form_alter to reorder the fields.
3. Create a form using Drupal fields and the mailchimp field instead of using the signup block. This might require something like Entity Form.
4. Write a patch for MailChimp module to allow the fields to be reordered in the admin UI for signup block.
~Greg
Comment #3
cmckay CreditAttribution: cmckay commentedThanks Greg!
Comment #4
Greg BoggsComment #5
Greg BoggsIf you come up with a good solution you want to share with the world, let us know!
Comment #6
cmckay CreditAttribution: cmckay commentedGreg, I actually had another idea. Shouldn't I be able to just specify the order in a template file?
I am able to use
block--mailchimp_signup.html.twig
to target the block, but cannot figure out the field names that I should be targeting.Do you have any suggestions?
Comment #7
Greg BoggsI've never tried to use a Twig template to build a drupal form. But, I believe it should work. My coworker's talk from DrupalCon will help you figure out how to do this:
https://events.drupal.org/baltimore2017/sessions/demystifying-rendered-c...
Comment #8
cmckay CreditAttribution: cmckay commentedSweet thanks!
Comment #9
cmckay CreditAttribution: cmckay commentedUgh - the video had some great tips, but didn't help with this use case. I just ended up doing this with JS.
Comment #10
Greg BoggsYea, I'm not really sure how to use Twig for a Drupal form. So, JS for the win. :)
Comment #11
junaidpvI developed a patch implementing this feature as well as additional other customization. Please see #3390459: Customize display of signup fields.