Created
April 29, 2011 10:36
-
-
Save skeller1/948159 to your computer and use it in GitHub Desktop.
form of project
This file contains 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
<%# project form partial %> | |
<%= form_for(@project) do |f| %> | |
<% if @project.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2> | |
<ul> | |
<% @project.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<div class="field"> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</div> | |
<%= nested_form_for @project do |p| %> | |
<%= p.fields_for :tasks do |t| %> | |
<%= t.label :name %> | |
<%= t.text_field :name %> | |
<%= t.link_to_remove "Remove Task" %> | |
<% end %> | |
<%= p.link_to_add "Add Task", :tasks %> | |
<% end %> | |
<div class="actions"> | |
<%= f.submit %> | |
</div> | |
<% end %> |
This file contains 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
class Project < ActiveRecord::Base | |
has_many :tasks | |
accepts_nested_attributes_for :tasks, :allow_destroy => true, :reject_if => :all_blank | |
end | |
class Task < ActiveRecord::Base | |
belongs_to :project | |
end |
This file contains 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
<html><head> | |
<title>NestedTest</title> | |
<link type="text/css" rel="stylesheet" media="screen" href="/stylesheets/scaffold.css?1304069618"> | |
<script type="text/javascript" src="/javascripts/prototype.js?1304069596"></script> | |
<script type="text/javascript" src="/javascripts/effects.js?1304069596"></script> | |
<script type="text/javascript" src="/javascripts/dragdrop.js?1304069596"></script> | |
<script type="text/javascript" src="/javascripts/controls.js?1304069596"></script> | |
<script type="text/javascript" src="/javascripts/rails.js?1304069596"></script> | |
<script type="text/javascript" src="/javascripts/nested_form.js?1304072118"></script> | |
<script type="text/javascript" src="/javascripts/application.js?1304069596"></script> | |
<meta content="authenticity_token" name="csrf-param"> | |
<meta content="oXPEcwl/yMToKkAa6mjm2DqqqzWoO2B2Ap8m+rCZeCs=" name="csrf-token"> | |
</head><body> | |
<h1>New project</h1> | |
<form method="post" id="new_project" class="new_project" action="/projects" accept-charset="UTF-8"><div style="margin: 0pt; padding: 0pt; display: inline;"><input type="hidden" value="✓" name="utf8"><input type="hidden" value="oXPEcwl/yMToKkAa6mjm2DqqqzWoO2B2Ap8m+rCZeCs=" name="authenticity_token"></div> | |
<div class="field"> | |
<label for="project_name">Name</label><br> | |
<input type="text" size="30" name="project[name]" id="project_name"> | |
</div> | |
<div style="margin: 0pt; padding: 0pt; display: inline;"><input type="hidden" value="✓" name="utf8"><input type="hidden" value="oXPEcwl/yMToKkAa6mjm2DqqqzWoO2B2Ap8m+rCZeCs=" name="authenticity_token"></div> | |
<a data-association="tasks" class="add_nested_fields" href="javascript:void(0)">Add Task</a> | |
</form><div style="display: none;" id="tasks_fields_blueprint"><div class="fields"> | |
<label for="project_tasks_attributes_new_tasks_name">Name</label> | |
<input type="text" size="30" name="project[tasks_attributes][new_tasks][name]" id="project_tasks_attributes_new_tasks_name"> | |
<input type="hidden" value="false" name="project[tasks_attributes][new_tasks][_destroy]" id="project_tasks_attributes_new_tasks__destroy"><a class="remove_nested_fields" href="javascript:void(0)">Remove Task</a> | |
</div></div> | |
<div class="actions"> | |
<input type="submit" value="Create Project" name="commit" id="project_submit"> | |
</div> | |
<a href="/projects">Back</a> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment