<% has_ndbn = @ingredient.ndbn.present? %> <%= form_for(@ingredient, html: {id: 'ingredient_form'}) do |f| %> <%= render partial: 'shared/error_list', locals: {model: @ingredient} %> <%= f.hidden_field :ndbn, class: 'ndbn' %> <%= f.hidden_field :id, class: 'id', disabled: true %>
<%= f.label :name, class: 'control-label' %> <%= f.text_field :name, class: 'form-control name', autofocus: true %>
<%= f.label :ndbn, "Nutrient Databank Number", class: 'control-label' %>

<%= @ingredient.ndbn ? UsdaFood.find_by_ndbn(@ingredient.ndbn).short_description : '' %>

<%= f.label :density, class: 'control-label' %> <%= f.text_field :density, class: 'form-control', disabled: has_ndbn %>
<%= f.label :notes, class: 'control-label' %> <%= f.text_area :notes, class: 'form-control' %>
Per 100 Grams
<%= f.label :water, "Grams of Water", class: 'control-label' %> <%= f.text_field :water, class: 'form-control', disabled: has_ndbn %>
<%= f.label :protein, "Grams of Protein", class: 'control-label' %> <%= f.text_field :protein, class: 'form-control', disabled: has_ndbn %>
<%= f.label :lipids, "Grams of Fat", class: 'control-label' %> <%= f.text_field :lipids, class: 'form-control', disabled: has_ndbn %>
<%= f.label :kcal, "Calories", class: 'control-label' %> <%= f.text_field :kcal, class: 'form-control', disabled: has_ndbn %>
<%= f.label :fiber, "Grams of Fiber", class: 'control-label' %> <%= f.text_field :fiber, class: 'form-control', disabled: has_ndbn %>
<%= f.label :sugar, "Grams of Sugar", class: 'control-label' %> <%= f.text_field :sugar, class: 'form-control', disabled: has_ndbn %>
<%= f.submit class: 'btn btn-primary' %>
<% end %>