Skip to content

Instantly share code, notes, and snippets.

@andyh
Last active January 3, 2016 06:39
Show Gist options
  • Save andyh/8424361 to your computer and use it in GitHub Desktop.
Save andyh/8424361 to your computer and use it in GitHub Desktop.
<%= form_for @contact, :remote => true, :url => contacts_path, :html => { :novalidate => '' } do |f| %>
<% if SpreeContactUs.require_name %>
<p>
<%= f.label :name, :class=>'label-field-control' %>
<%= f.text_field :name, class: 'form-control' %>
</p>
<% end %>
<p>
<%= f.label :email, :class=>'label-field-control' %>
<span class="required">(required)</span><br/>
<%= f.email_field :email, class: 'form-control required email' %>
</p>
<% if SpreeContactUs.require_subject %>
<p>
<%= f.label :subject, :class=>'label-field-control' %>
<%= f.text_field :subject, class: 'form-control' %>
</p>
<% end %>
<p>
<%= f.label :message, :class=>'label-field-control' %>
<span class="required">(required)</span><br/>
<%= f.text_area :message, class: 'form-control required' %>
</p>
<p>
<%= f.submit 'Submit', :class => 'btn-minimal',:alt => t('submit'), :id => 'contact_us_contact_submit', :title => t('submit') %>
</p>
<% end %>
class Spree::ContactUs::ContactsController < Spree::StoreController
respond_to :html, :js
helper "spree/products"
def create
@contact = Spree::ContactUs::Contact.new(params[:contact_us_contact])
@contact.save
respond_with @contact
end
def new
@contact = Spree::ContactUs::Contact.new
end
private
def accurate_title
t('contact_us')
end
end
$("#new_contact_us_contact").html("Thanks")
<strong class="title">Online Form</strong>
<%= render :partial => 'form' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment