Use a proper struct for the contact’s form
Our company is a kind-of contact, although it does not appear in the contact section, thus i could embed the contact form inside the tax details form to reuse all the common fields.
This commit is contained in:
parent
e8523e373f
commit
7a439a40cc
135
pkg/company.go
135
pkg/company.go
|
@ -84,109 +84,13 @@ type Tax struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type taxDetailsForm struct {
|
type taxDetailsForm struct {
|
||||||
locale *Locale
|
*contactForm
|
||||||
BusinessName *InputField
|
|
||||||
VATIN *InputField
|
|
||||||
TradeName *InputField
|
|
||||||
Phone *InputField
|
|
||||||
Email *InputField
|
|
||||||
Web *InputField
|
|
||||||
Address *InputField
|
|
||||||
City *InputField
|
|
||||||
Province *InputField
|
|
||||||
PostalCode *InputField
|
|
||||||
Country *SelectField
|
|
||||||
Currency *SelectField
|
Currency *SelectField
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaxDetailsForm(ctx context.Context, conn *Conn, locale *Locale) *taxDetailsForm {
|
func newTaxDetailsForm(ctx context.Context, conn *Conn, locale *Locale) *taxDetailsForm {
|
||||||
return &taxDetailsForm{
|
return &taxDetailsForm{
|
||||||
locale: locale,
|
contactForm: newContactForm(ctx, conn, locale),
|
||||||
BusinessName: &InputField{
|
|
||||||
Name: "business_name",
|
|
||||||
Label: pgettext("input", "Business name", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="organization"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
VATIN: &InputField{
|
|
||||||
Name: "vatin",
|
|
||||||
Label: pgettext("input", "VAT number", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
TradeName: &InputField{
|
|
||||||
Name: "trade_name",
|
|
||||||
Label: pgettext("input", "Trade name", locale),
|
|
||||||
Type: "text",
|
|
||||||
},
|
|
||||||
Phone: &InputField{
|
|
||||||
Name: "phone",
|
|
||||||
Label: pgettext("input", "Phone", locale),
|
|
||||||
Type: "tel",
|
|
||||||
Required: true,
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="tel"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Email: &InputField{
|
|
||||||
Name: "email",
|
|
||||||
Label: pgettext("input", "Email", locale),
|
|
||||||
Type: "email",
|
|
||||||
Required: true,
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="email"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Web: &InputField{
|
|
||||||
Name: "web",
|
|
||||||
Label: pgettext("input", "Web", locale),
|
|
||||||
Type: "url",
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="url"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Address: &InputField{
|
|
||||||
Name: "address",
|
|
||||||
Label: pgettext("input", "Address", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="address-line1"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
City: &InputField{
|
|
||||||
Name: "city",
|
|
||||||
Label: pgettext("input", "City", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
Province: &InputField{
|
|
||||||
Name: "province",
|
|
||||||
Label: pgettext("input", "Province", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
PostalCode: &InputField{
|
|
||||||
Name: "postal_code",
|
|
||||||
Label: pgettext("input", "Postal code", locale),
|
|
||||||
Type: "text",
|
|
||||||
Required: true,
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="postal-code"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Country: &SelectField{
|
|
||||||
Name: "country",
|
|
||||||
Label: pgettext("input", "Country", locale),
|
|
||||||
Options: mustGetCountryOptions(ctx, conn, locale),
|
|
||||||
Selected: "ES",
|
|
||||||
Attributes: []template.HTMLAttr{
|
|
||||||
`autocomplete="country"`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Currency: &SelectField{
|
Currency: &SelectField{
|
||||||
Name: "currency",
|
Name: "currency",
|
||||||
Label: pgettext("input", "Currency", locale),
|
Label: pgettext("input", "Currency", locale),
|
||||||
|
@ -197,48 +101,17 @@ func newTaxDetailsForm(ctx context.Context, conn *Conn, locale *Locale) *taxDeta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (form *taxDetailsForm) Parse(r *http.Request) error {
|
func (form *taxDetailsForm) Parse(r *http.Request) error {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := form.contactForm.Parse(r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
form.BusinessName.FillValue(r)
|
|
||||||
form.VATIN.FillValue(r)
|
|
||||||
form.TradeName.FillValue(r)
|
|
||||||
form.Phone.FillValue(r)
|
|
||||||
form.Email.FillValue(r)
|
|
||||||
form.Web.FillValue(r)
|
|
||||||
form.Address.FillValue(r)
|
|
||||||
form.City.FillValue(r)
|
|
||||||
form.Province.FillValue(r)
|
|
||||||
form.PostalCode.FillValue(r)
|
|
||||||
form.Country.FillValue(r)
|
|
||||||
form.Currency.FillValue(r)
|
form.Currency.FillValue(r)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (form *taxDetailsForm) Validate(ctx context.Context, conn *Conn) bool {
|
func (form *taxDetailsForm) Validate(ctx context.Context, conn *Conn) bool {
|
||||||
validator := newFormValidator()
|
validator := newFormValidator()
|
||||||
validator.CheckRequiredInput(form.BusinessName, gettext("Business name can not be empty.", form.locale))
|
|
||||||
if validator.CheckRequiredInput(form.VATIN, gettext("VAT number can not be empty.", form.locale)) {
|
|
||||||
validator.CheckValidVATINInput(form.VATIN, form.Country.Selected, gettext("This value is not a valid VAT number.", form.locale))
|
|
||||||
}
|
|
||||||
if validator.CheckRequiredInput(form.Phone, gettext("Phone can not be empty.", form.locale)) {
|
|
||||||
validator.CheckValidPhoneInput(form.Phone, form.Country.Selected, gettext("This value is not a valid phone number.", form.locale))
|
|
||||||
}
|
|
||||||
if validator.CheckRequiredInput(form.Email, gettext("Email can not be empty.", form.locale)) {
|
|
||||||
validator.CheckValidEmailInput(form.Email, gettext("This value is not a valid email. It should be like name@domain.com.", form.locale))
|
|
||||||
}
|
|
||||||
if form.Web.Val != "" {
|
|
||||||
validator.checkValidURL(form.Web, gettext("This value is not a valid web address. It should be like https://domain.com/.", form.locale))
|
|
||||||
}
|
|
||||||
validator.CheckRequiredInput(form.Address, gettext("Address can not be empty.", form.locale))
|
|
||||||
validator.CheckRequiredInput(form.City, gettext("City can not be empty.", form.locale))
|
|
||||||
validator.CheckRequiredInput(form.Province, gettext("Province can not be empty.", form.locale))
|
|
||||||
if validator.CheckRequiredInput(form.PostalCode, gettext("Postal code can not be empty.", form.locale)) {
|
|
||||||
validator.CheckValidPostalCode(ctx, conn, form.PostalCode, form.Country.Selected, gettext("This value is not a valid postal code.", form.locale))
|
|
||||||
}
|
|
||||||
validator.CheckValidSelectOption(form.Country, gettext("Selected country is not valid.", form.locale))
|
|
||||||
validator.CheckValidSelectOption(form.Currency, gettext("Selected currency is not valid.", form.locale))
|
validator.CheckValidSelectOption(form.Currency, gettext("Selected currency is not valid.", form.locale))
|
||||||
return validator.AllOK()
|
return form.contactForm.Validate(ctx, conn) && validator.AllOK()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (form *taxDetailsForm) mustFillFromDatabase(ctx context.Context, conn *Conn, company *Company) *taxDetailsForm {
|
func (form *taxDetailsForm) mustFillFromDatabase(ctx context.Context, conn *Conn, company *Company) *taxDetailsForm {
|
||||||
|
|
192
pkg/contacts.go
192
pkg/contacts.go
|
@ -2,6 +2,7 @@ package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,22 +21,18 @@ func ContactsHandler() http.Handler {
|
||||||
conn := getConn(r)
|
conn := getConn(r)
|
||||||
company := getCompany(r)
|
company := getCompany(r)
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
r.ParseForm()
|
locale := getLocale(r)
|
||||||
page := &NewContactPage{
|
form := newContactForm(r.Context(), conn, locale)
|
||||||
BusinessName: r.FormValue("business_name"),
|
if err := form.Parse(r); err != nil {
|
||||||
VATIN: r.FormValue("vatin"),
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
TradeName: r.FormValue("trade_name"),
|
return
|
||||||
Phone: r.FormValue("phone"),
|
|
||||||
Email: r.FormValue("email"),
|
|
||||||
Web: r.FormValue("web"),
|
|
||||||
Address: r.FormValue("address"),
|
|
||||||
City: r.FormValue("city"),
|
|
||||||
Province: r.FormValue("province"),
|
|
||||||
PostalCode: r.FormValue("postal_code"),
|
|
||||||
CountryCode: r.FormValue("country"),
|
|
||||||
}
|
}
|
||||||
conn.MustExec(r.Context(), "insert into contact (company_id, business_name, vatin, trade_name, phone, email, web, address, province, city, postal_code, country_code) values ($1, $2, ($12 || $3)::vatin, $4, parse_packed_phone_number($5, $12), $6, $7, $8, $9, $10, $11, $12)", company.Id, page.BusinessName, page.VATIN, page.TradeName, page.Phone, page.Email, page.Web, page.Address, page.City, page.Province, page.PostalCode, page.CountryCode)
|
if form.Validate(r.Context(), conn) {
|
||||||
|
conn.MustExec(r.Context(), "insert into contact (company_id, business_name, vatin, trade_name, phone, email, web, address, province, city, postal_code, country_code) values ($1, $2, ($12 || $3)::vatin, $4, parse_packed_phone_number($5, $12), $6, $7, $8, $9, $10, $11, $12)", company.Id, form.BusinessName, form.VATIN, form.TradeName, form.Phone, form.Email, form.Web, form.Address, form.City, form.Province, form.PostalCode, form.Country)
|
||||||
http.Redirect(w, r, "/company/"+company.Slug+"/contacts", http.StatusSeeOther)
|
http.Redirect(w, r, "/company/"+company.Slug+"/contacts", http.StatusSeeOther)
|
||||||
|
} else {
|
||||||
|
mustRenderAppTemplate(w, r, "contacts-new.gohtml", form)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
page := &ContactsIndexPage{
|
page := &ContactsIndexPage{
|
||||||
Contacts: mustGetContactEntries(r.Context(), conn, company),
|
Contacts: mustGetContactEntries(r.Context(), conn, company),
|
||||||
|
@ -68,29 +65,160 @@ func mustGetContactEntries(ctx context.Context, conn *Conn, company *Company) []
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewContactPage struct {
|
type contactForm struct {
|
||||||
BusinessName string
|
locale *Locale
|
||||||
VATIN string
|
BusinessName *InputField
|
||||||
TradeName string
|
VATIN *InputField
|
||||||
Phone string
|
TradeName *InputField
|
||||||
Email string
|
Phone *InputField
|
||||||
Web string
|
Email *InputField
|
||||||
Address string
|
Web *InputField
|
||||||
City string
|
Address *InputField
|
||||||
Province string
|
City *InputField
|
||||||
PostalCode string
|
Province *InputField
|
||||||
CountryCode string
|
PostalCode *InputField
|
||||||
Countries []*SelectOption
|
Country *SelectField
|
||||||
|
}
|
||||||
|
|
||||||
|
func newContactForm(ctx context.Context, conn *Conn, locale *Locale) *contactForm {
|
||||||
|
return &contactForm{
|
||||||
|
locale: locale,
|
||||||
|
BusinessName: &InputField{
|
||||||
|
Name: "business_name",
|
||||||
|
Label: pgettext("input", "Business name", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="organization"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
VATIN: &InputField{
|
||||||
|
Name: "vatin",
|
||||||
|
Label: pgettext("input", "VAT number", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
TradeName: &InputField{
|
||||||
|
Name: "trade_name",
|
||||||
|
Label: pgettext("input", "Trade name", locale),
|
||||||
|
Type: "text",
|
||||||
|
},
|
||||||
|
Phone: &InputField{
|
||||||
|
Name: "phone",
|
||||||
|
Label: pgettext("input", "Phone", locale),
|
||||||
|
Type: "tel",
|
||||||
|
Required: true,
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="tel"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Email: &InputField{
|
||||||
|
Name: "email",
|
||||||
|
Label: pgettext("input", "Email", locale),
|
||||||
|
Type: "email",
|
||||||
|
Required: true,
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="email"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Web: &InputField{
|
||||||
|
Name: "web",
|
||||||
|
Label: pgettext("input", "Web", locale),
|
||||||
|
Type: "url",
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="url"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Address: &InputField{
|
||||||
|
Name: "address",
|
||||||
|
Label: pgettext("input", "Address", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="address-line1"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
City: &InputField{
|
||||||
|
Name: "city",
|
||||||
|
Label: pgettext("input", "City", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
Province: &InputField{
|
||||||
|
Name: "province",
|
||||||
|
Label: pgettext("input", "Province", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
PostalCode: &InputField{
|
||||||
|
Name: "postal_code",
|
||||||
|
Label: pgettext("input", "Postal code", locale),
|
||||||
|
Type: "text",
|
||||||
|
Required: true,
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="postal-code"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Country: &SelectField{
|
||||||
|
Name: "country",
|
||||||
|
Label: pgettext("input", "Country", locale),
|
||||||
|
Options: mustGetCountryOptions(ctx, conn, locale),
|
||||||
|
Selected: "ES",
|
||||||
|
Attributes: []template.HTMLAttr{
|
||||||
|
`autocomplete="country"`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (form *contactForm) Parse(r *http.Request) error {
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
form.BusinessName.FillValue(r)
|
||||||
|
form.VATIN.FillValue(r)
|
||||||
|
form.TradeName.FillValue(r)
|
||||||
|
form.Phone.FillValue(r)
|
||||||
|
form.Email.FillValue(r)
|
||||||
|
form.Web.FillValue(r)
|
||||||
|
form.Address.FillValue(r)
|
||||||
|
form.City.FillValue(r)
|
||||||
|
form.Province.FillValue(r)
|
||||||
|
form.PostalCode.FillValue(r)
|
||||||
|
form.Country.FillValue(r)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (form *contactForm) Validate(ctx context.Context, conn *Conn) bool {
|
||||||
|
validator := newFormValidator()
|
||||||
|
validator.CheckRequiredInput(form.BusinessName, gettext("Business name can not be empty.", form.locale))
|
||||||
|
if validator.CheckRequiredInput(form.VATIN, gettext("VAT number can not be empty.", form.locale)) {
|
||||||
|
validator.CheckValidVATINInput(form.VATIN, form.Country.Selected, gettext("This value is not a valid VAT number.", form.locale))
|
||||||
|
}
|
||||||
|
if validator.CheckRequiredInput(form.Phone, gettext("Phone can not be empty.", form.locale)) {
|
||||||
|
validator.CheckValidPhoneInput(form.Phone, form.Country.Selected, gettext("This value is not a valid phone number.", form.locale))
|
||||||
|
}
|
||||||
|
if validator.CheckRequiredInput(form.Email, gettext("Email can not be empty.", form.locale)) {
|
||||||
|
validator.CheckValidEmailInput(form.Email, gettext("This value is not a valid email. It should be like name@domain.com.", form.locale))
|
||||||
|
}
|
||||||
|
if form.Web.Val != "" {
|
||||||
|
validator.checkValidURL(form.Web, gettext("This value is not a valid web address. It should be like https://domain.com/.", form.locale))
|
||||||
|
}
|
||||||
|
validator.CheckRequiredInput(form.Address, gettext("Address can not be empty.", form.locale))
|
||||||
|
validator.CheckRequiredInput(form.City, gettext("City can not be empty.", form.locale))
|
||||||
|
validator.CheckRequiredInput(form.Province, gettext("Province can not be empty.", form.locale))
|
||||||
|
if validator.CheckRequiredInput(form.PostalCode, gettext("Postal code can not be empty.", form.locale)) {
|
||||||
|
validator.CheckValidPostalCode(ctx, conn, form.PostalCode, form.Country.Selected, gettext("This value is not a valid postal code.", form.locale))
|
||||||
|
}
|
||||||
|
validator.CheckValidSelectOption(form.Country, gettext("Selected country is not valid.", form.locale))
|
||||||
|
return validator.AllOK()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContactHandler() http.Handler {
|
func NewContactHandler() http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
locale := getLocale(r)
|
locale := getLocale(r)
|
||||||
conn := getConn(r)
|
conn := getConn(r)
|
||||||
page := &NewContactPage{
|
form := newContactForm(r.Context(), conn, locale)
|
||||||
CountryCode: "ES",
|
mustRenderAppTemplate(w, r, "contacts-new.gohtml", form)
|
||||||
Countries: mustGetCountryOptions(r.Context(), conn, locale),
|
|
||||||
}
|
|
||||||
mustRenderAppTemplate(w, r, "contacts-new.gohtml", page)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,55 +6,17 @@
|
||||||
<section class="dialog-content">
|
<section class="dialog-content">
|
||||||
<h2>{{(pgettext "New Contact" "title")}}</h2>
|
<h2>{{(pgettext "New Contact" "title")}}</h2>
|
||||||
<form method="POST" action="{{ companyURI "/contacts" }}">
|
<form method="POST" action="{{ companyURI "/contacts" }}">
|
||||||
<div class="input">
|
{{ template "input-field" .BusinessName | addInputAttr "autofocus" }}
|
||||||
<input type="text" name="business_name" id="business_name" required="required" autofocus value="{{ .BusinessName }}" placeholder="{{( pgettext "Business name" "input" )}}">
|
{{ template "input-field" .VATIN }}
|
||||||
<label for="business_name">{{( pgettext "Business name" "input" )}}</label>
|
{{ template "input-field" .TradeName }}
|
||||||
</div>
|
{{ template "input-field" .Phone }}
|
||||||
<div class="input">
|
{{ template "input-field" .Email }}
|
||||||
<input type="text" name="vatin" id="vatin" required="required" value="{{ .VATIN }}" placeholder="{{( pgettext "VAT number" "input" )}}">
|
{{ template "input-field" .Web }}
|
||||||
<label for="vatin">{{( pgettext "VAT number" "input" )}}</label>
|
{{ template "input-field" .Address | addInputAttr `class="width-2x"` }}
|
||||||
</div>
|
{{ template "input-field" .City }}
|
||||||
<div class="input">
|
{{ template "input-field" .Province }}
|
||||||
<input type="text" name="trade_name" id="trade_name" value="{{ .TradeName }}" placeholder="{{( pgettext "Trade name" "input" )}}">
|
{{ template "input-field" .PostalCode }}
|
||||||
<label for="trade_name">{{( pgettext "Trade name" "input" )}}</label>
|
{{ template "select-field" .Country | addSelectAttr `class="width-fixed"` }}
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="tel" name="phone" id="phone" required="required" value="{{ .Phone }}" placeholder="{{( pgettext "Phone" "input" )}}">
|
|
||||||
<label for="phone">{{( pgettext "Phone" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="email" name="email" id="email" required="required" value="{{ .Email }}" placeholder="{{( pgettext "Email" "input" )}}">
|
|
||||||
<label for="email">{{( pgettext "Email" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="url" name="web" id="web" value="{{ .Web }}" placeholder="{{( pgettext "Web" "input" )}}">
|
|
||||||
<label for="web">{{( pgettext "Web" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="text" name="address" id="address" class="width-2x" required="required" value="{{ .Address }}" placeholder="{{( pgettext "Address" "input" )}}">
|
|
||||||
<label for="address">{{( pgettext "Address" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="text" name="city" id="city" required="required" value="{{ .City }}" placeholder="{{( pgettext "City" "input" )}}">
|
|
||||||
<label for="city">{{( pgettext "City" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="text" name="province" id="province" required="required" value="{{ .City }}" placeholder="{{( pgettext "Province" "input" )}}">
|
|
||||||
<label for="province">{{( pgettext "Province" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<input type="text" name="postal_code" id="postal_code" required="required" value="{{ .PostalCode }}" placeholder="{{( pgettext "Postal code" "input" )}}">
|
|
||||||
<label for="postal_code">{{( pgettext "Postal code" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input">
|
|
||||||
<select id="country" name="country" class="width-fixed">
|
|
||||||
{{- range $country := .Countries }}
|
|
||||||
<option value="{{ .Value }}" {{ if eq .Value $.CountryCode }}selected="selected"{{ end }}>{{ .Label }}</option>
|
|
||||||
{{- end }}
|
|
||||||
</select>
|
|
||||||
<label for="country">{{( pgettext "Country" "input" )}}</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<button type="submit">{{( pgettext "New contact" "action" )}}</button>
|
<button type="submit">{{( pgettext "New contact" "action" )}}</button>
|
||||||
|
|
Loading…
Reference in New Issue