<% # Unclear why this url/method hack is needed %> <%= form_for @account, :url => @account.persisted? ? account_path(@account.account_id) : accounts_path, :method => @account.persisted? ? :put : :post, :html => {:class => 'form-horizontal'} do |f| %>
<%= f.label :name, 'Name', :class => 'col-sm-3 control-label' %>
<%= f.text_field :name, :class => 'form-control' %>
<%= f.label :first_name_length, 'First name length', :class => 'col-sm-3 control-label' %>
<%= f.text_field :first_name_length, :class => 'form-control' %>
<% unless @account.persisted? %>
<%= f.label :external_key, 'External key', :class => 'col-sm-3 control-label' %>
<%= f.text_field :external_key, :class => 'form-control' %>
<% else %> <%= f.hidden_field :external_key %> <% end %>
<%= f.label :email, 'Email', :class => 'col-sm-3 control-label' %>
<%= f.text_field :email, :class => 'form-control' %>
<% unless @account.persisted? %>
<%= f.label :bill_cycle_day_local, 'Bill cycle day', :class => 'col-sm-3 control-label' %>
<%= f.text_field :bill_cycle_day_local, :class => 'form-control' %>
<%= f.label :currency, 'Currency', :class => 'col-sm-3 control-label' %>
<%= f.select :currency, currencies, {:selected => 'USD'}, :class => 'form-control' %>
<%= f.label :time_zone, 'Timezone', :class => 'col-sm-3 control-label' %>
<%= f.collection_select :time_zone, ActiveSupport::TimeZone.all, :formatted_offset, :to_s, {:selected => Time.zone.formatted_offset}, :class => 'form-control' %>
<% else %> <%= f.hidden_field :bill_cycle_day_local %> <%= f.hidden_field :currency %> <%= f.hidden_field :time_zone %> <% end %>
<%= f.label :locale, 'Locale', :class => 'col-sm-3 control-label' %>
<%= f.text_field :locale, :class => 'form-control' %>
<%= f.label :address1, 'Address line 1', :class => 'col-sm-3 control-label' %>
<%= f.text_field :address1, :class => 'form-control' %>
<%= f.label :address2, 'Address line 2', :class => 'col-sm-3 control-label' %>
<%= f.text_field :address2, :class => 'form-control' %>
<%= f.label :postal_code, 'Zip code', :class => 'col-sm-3 control-label' %>
<%= f.text_field :postal_code, :class => 'form-control' %>
<%= f.label :company, 'Company', :class => 'col-sm-3 control-label' %>
<%= f.text_field :company, :class => 'form-control' %>
<%= f.label :city, 'City', :class => 'col-sm-3 control-label' %>
<%= f.text_field :city, :class => 'form-control' %>
<%= f.label :state, 'State', :class => 'col-sm-3 control-label' %>
<%= f.text_field :state, :class => 'form-control' %>
<%= f.label :country, 'Country', :class => 'col-sm-3 control-label' %>
<%= f.country_select :country, {:priority => %w(US CA), :selected => @account.country}, :class => 'form-control' %>
<%= f.label :phone, 'Phone', :class => 'col-sm-3 control-label' %>
<%= f.text_field :phone, :class => 'form-control' %>
<%= f.label :notes, 'Notes', :class => 'col-sm-3 control-label' %>
<%= f.text_field :notes, :class => 'form-control' %>
<% unless @account.persisted? %>
<%= f.label :is_migrated do %> <%= f.check_box :is_migrated, {:checked => @account.is_migrated} %>Migrated? <% end %>
<% else %> <%= f.hidden_field :is_migrated %> <% end %>
<%= f.label :is_notified_for_invoices do %> <%= f.check_box :is_notified_for_invoices, {:checked => @account.is_notified_for_invoices} %>Notified for invoices? <% end %>
<%= submit_tag 'Save', :class => 'btn btn-default' %>
<% end %>