Created
August 21, 2009 17:28
-
-
Save supaspoida/172205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Having some trouble using merb-parts to render a mailing list signup form. Tried with both Haml & Erb and can get the expected results. | |
Here is the source for the part I'm using: | |
class ContactFormPart < Merb::PartController | |
def new | |
@contact = Contact.new | |
@redirect_to = params[:redirect_to] | |
render | |
end | |
end | |
And the call to the part (haml): | |
#sidebar | |
= part ContactFormPart => :new, :redirect_to => url(:about) | |
And the new.html.erb template/output: | |
<%= form_for(@contact, :action => url(:contacts)) do -%> | |
<p> | |
<%= text_field :name, :label => 'Full Name' %> | |
</p> | |
<p> | |
<%= text_field :email, :label => 'Email' %> | |
</p> | |
<p> | |
<%= submit "Save", :class => 'button' %> | |
</p> | |
<p> | |
<%= hidden_field :name => :redirect_to, :value => @redirect_to %> | |
</p> | |
<%- end =%> | |
<div id='sidebar'> | |
<p> | |
<label for="contact_name">Full Name</label><input type="text" value=" " class="text" name="contact[name]" id="contact_name"/> | |
</p> | |
<p> | |
<label for="contact_email">Email</label><input type="text" value="" class="text" name="contact[email]" id="contact_email"/> | |
</p> | |
<p> | |
<input type="submit" value="Save" class="button" name="submit" id="submit"/> | |
</p> | |
<p> | |
<input type="hidden" value="/about" class="hidden" name="redirect_to" id="redirect_to"/> | |
</p> | |
<form method="post" action="/contacts"> | |
<p> | |
<label for="contact_name">Full Name</label><input type="text" value=" " class="text" name="contact[name]" id="contact_name"/> | |
</p> | |
<p> | |
<label for="contact_email">Email</label><input type="text" value="" class="text" name="contact[email]" id="contact_email"/> | |
</p> | |
<p> | |
<input type="submit" value="Save" class="button" name="submit" id="submit"/> | |
</p> | |
<p> | |
<input type="hidden" value="/about" class="hidden" name="redirect_to" id="redirect_to"/> | |
</p> | |
</form> | |
</div> | |
And the new.html.haml template/output | |
.mailing_list_signup | |
= form_for(@contact, :action => url(:contacts)) do | |
%p= text_field :name, :label => 'Full Name' | |
%p= text_field :email, :label => 'Email' | |
= hidden_field :name => :redirect_to, :value => @redirect_to | |
%p= submit "Save", :class => 'button' | |
<div id='sidebar'> | |
<div class='mailing_list_signup'> | |
<p> | |
<label for="contact_name">Full Name</label><input type="text" value=" " class="text" name="contact[name]" id="contact_name"/> | |
</p> | |
<p> | |
<label for="contact_email">Email</label><input type="text" value="" class="text" name="contact[email]" id="contact_email"/> | |
</p> | |
<input type="hidden" value="/about" class="hidden" name="redirect_to" id="redirect_to"/> | |
<p> | |
<input type="submit" value="Save" class="button" name="submit" id="submit"/> | |
</p> | |
<form method="post" action="/contacts">1</form> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment