Hello,

I would like a user to fill out a form (a long contract) and then email
it to them, including the new values.

So I was leaning towards a partial or layout so I didn't have to write
the contract twice.  But that's where I run into problems.  The only
difference between the form (contract) and the email are the form tags
will be replaced with their actual values.  For example:

My HTML Contract
<% form_for @contract, :url => { :action => "send_contract"} do |f| %>
  <%= f.error_messages %>
  <div>
    Lots of text that I don't want to duplicate
  </div>
  <div>
    <%= f.label :name, "Name: " %>
    <%= f.text_field :name %>
  </div>
  <div>
    <%= f.label :email, "Email: " %>
    <%= f.text_field :email %>
  </div>
  <div>
    Lots more text that I don't want to duplicate
  </div>
  ...
<% end %>

My Email Contract
<div>
  Lots of text that I don't want to duplicate
</div>
<div>
  <%= "Name: " %>
  <%= @email[:name] %>
</div>
<div>
  <%= "Email: " %>
  <%= @email[:name] %>
</div>
<div>
  Lots more text that I don't want to duplicate
</div>

My goal:
<% if params[:action] == "contract" %>
  <% form_for @contract, :url => { :action => "send_contract"} do |f| %>
  <%= f.error_messages %>
<% end %>
<div>
  Lots of text that I don't want to duplicate
</div>
<div>
  <% if params[:action] == "contract" %>
    <%= f.label :name, "Name: " %>
    <%= f.text_field :name %>
  <% else %>
    <%= "Name: " %>
    <%= @email[:name] %>
  <% end %>
</div>
<div>
  <% if params[:action] == "contract" %>
    <%= f.label :email, "Email: " %>
    <%= f.text_field :email %>
  <% else %>
    <%= "Email: " %>
    <%= @email[:name] %>
  <% end %>
</div>
<div>
  Lots more text that I don't want to duplicate
</div>
<% if params[:action] == "contract" %>
  <% end %>
<% end %>

Obviously, this doesn't work. Any ideas on how to leverage the shared
text while still maintaining a form?  I know I could use the form_tag
instead, but that wouldn't give me all the needed stuff that comes
with the form_for tag.

Adam
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to