Skip to content

Commit

Permalink
moved edit form into partial
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomascountz committed Aug 25, 2017
1 parent 8c5c1c3 commit 1f8ea95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
29 changes: 29 additions & 0 deletions app/views/expenses/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="row form-group">
<div class="col-md-6 col-md-offset-3">
<h1 class="center">New Expense</h1>
<%= form_for(expense) do |f| %>
<%= render 'shared/error_messages', object: expense %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title, autofocus: true, class: "form-control" %>
</div>

<div class="field">
<%= f.label :description%><br />
<%= f.text_area :description, class: "form-control" %>
</div>

<div class="field">
<%= f.label :amount %>
<%= f.number_field :amount, value: number_to_currency(f.object.amount.to_f, delimiter: '', unit: ''), step: 0.01, class: "form-control" %>
</div>

<br />

<div class="actions">
<%= f.submit "Submit", class: "btn btn-primary" %>
</div>

<% end %>
</div>
</div>
30 changes: 1 addition & 29 deletions app/views/expenses/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
<div class="row form-group">
<div class="col-md-6 col-md-offset-3">
<h1 class="center">New Expense</h1>
<%= form_for(@expense) do |f| %>
<%= render 'shared/error_messages', object: @expense %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title, autofocus: true, class: "form-control" %>
</div>

<div class="field">
<%= f.label :description%><br />
<%= f.text_area :description, class: "form-control" %>
</div>

<div class="field">
<%= f.label :amount %>
<%= f.number_field :amount, value: number_to_currency(f.object.amount.to_f, delimiter: '', unit: ''), step: 0.01, class: "form-control" %>
</div>

<br />

<div class="actions">
<%= f.submit "Submit", class: "btn btn-primary" %>
</div>

<% end %>
</div>
</div>
<%= render 'form', expense: @expense %>

0 comments on commit 1f8ea95

Please sign in to comment.