tenpn
tenpn

Reputation: 4716

Use bootstrap classes in mailchimp embedded form?

I'm a programmer but by trade not a web developer. I'm trying to knock together a simple site with bootstrap, and I want to embed a mailchimp signup form.

The embed code from mailchimp looks like this:

<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
    #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
    /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
       We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="<snip>" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <label for="mce-EMAIL">Subscribe to our mailing list</label>
    <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
    <div style="position: absolute; left: -5000px;"><input type="text" name="[some long alphanum code]" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</form>

This works, but doesn't blend in very well with the bootstrap columns or styling:

form screenshot

I tried to fiddle with things to use a bootstrap input group and trailing button, and got it working, but I'm a bit scared by this line of the original html:

<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="[some long alphanum code]" tabindex="-1" value=""></div>

How can I rewrite the form to use bootstrap grids and buttons, but still avoid bot signups?

Upvotes: 3

Views: 4488

Answers (1)

tenpn
tenpn

Reputation: 4716

This haml got me the styling I want, and when I unhid the honeypot and tried to submit, mailchimp kicked me back. So it looks like it's working.

.row
  .col-md-4
    %p.text-muted
      Product isn't out yet. Sign up to our newsletter to stay informed.
  .col-md-8
    %form#mc-embedded-subscribe-form.validate{:action => "<snip>",
                                            :method => "post",
                                            :name => "mc-embedded-subscribe-form",
                                            :novalidate => "",
                                            :target => "_blank"}
      / real people should not fill this in and expect good things - do not remove this or risk form bot signups
      %div{:style => "position: absolute; left: -5000px;"}
        %input{:name => "<some alphanum>",
               :tabindex => "-1",
               :type => "text",
               :value => ""}/
      .input-group.input-group-lg
        %input.form-control{:name => "EMAIL",
                            :placeholder => "[email protected]",
                            :required => "",
                            :type => "email",
                            :value => ""}
        %span.input-group-btn
          %button.btn.btn-primary{:name => "subscribe",
                                  :type => "submit",
                                  :value => "Subscribe"}
            Subscribe

Upvotes: 1

Related Questions