Preselect default values for new record #2776

This commit is contained in:
Priit Tark 2015-07-21 19:05:39 +03:00
parent dec7fcee13
commit cc672a420b
3 changed files with 7 additions and 11 deletions

View file

@ -144,13 +144,6 @@ module Depp
end
end
def initialize(attributes = {})
super
self.country_code = 'EE' if country_code.blank?
self.ident_type = 'bic' if ident_type.blank?
self.ident_country_code = 'EE' if ident_country_code.blank?
end
def save
create_xml = Depp::Contact.epp_xml.create(
{

View file

@ -30,5 +30,6 @@
.col-md-3.control-label
= f.label :country_code, t(:country) + '*'
.col-md-7
= f.select :country_code,
SortedCountry.all_options(f.object.country_code)
- country_selected = f.object.persisted? ? f.object.country_code : 'EE'
= f.select :country_code, SortedCountry.all_options(country_selected),
{ include_blank: true }

View file

@ -11,7 +11,8 @@
= Country.new(f.object.ident_country_code).try(:to_s)
= " [#{f.object.ident_country_code}]"
- else
= f.select(:ident_country_code, SortedCountry.all_options(f.object.ident_country_code), {},
- country_selected = @contact.persisted? ? '' : 'EE'
= f.select(:ident_country_code, SortedCountry.all_options(country_selected), {},
class: 'js-ident-country-code', required: true)
.form-group
@ -23,8 +24,9 @@
= Depp::Contact.type_string(f.object.ident_type)
= " [#{f.object.ident_type}]"
- else
- type_selected = @contact.persisted? ? '' : 'bic'
= f.select(:ident_type, Depp::Contact::SELECTION_TYPES,
{ selected: f.object.ident_type },
{ selected: type_selected },
class: 'js-ident-type', required: true)
.form-group