Skip to content

Commit

Permalink
[FIX] website_portal_address: fix country and state form
Browse files Browse the repository at this point in the history
- selected dropbox fix with correct id
- add label on fields
  • Loading branch information
mathben committed Mar 8, 2020
1 parent 4f9e947 commit 0109550
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion website_portal_address/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def portal_my_contacts_read(self, contact):
"fields": self._contacts_fields(),
}
)
return request.website.render(
return request.render(
"website_portal_contact.contacts_followup", values
)

Expand Down
48 changes: 29 additions & 19 deletions website_portal_address/views/contact_address.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
t-att-name="field_name"
t-att-type="'email' if field_name == 'email' else 'select' if field_name in ('country_id', 'state_id') else ('tel' if field_name in ('phone', 'mobile') else 'text')"
t-att-required="field_description['required'] and 'required'"
t-att-title="field_description['help'] or False"
t-att-value="contact[field_name]"
class="form-control"/>
<!-- <input-->
<!-- t-att-id="field_name"-->
<!-- t-att-name="field_name"-->
<!-- t-att-type="'email' if field_name == 'email' else 'select' if field_name in ('country_id', 'state_id') else ('tel' if field_name in ('phone', 'mobile') else 'text')"-->
<!-- t-att-required="field_description['required'] and 'required'"-->
<!-- t-att-title="field_description['help'] or False"-->
<!-- t-att-value="contact[field_name]"-->
<!-- class="form-control"/>-->
</div>
</div>
</t>
Expand All @@ -31,7 +38,7 @@
<label class="col-sm-3"></label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" id="radio212_contact"
<input type="radio" id="radio212_contact"
t-att-checked='"checked" if contact["type"] == "contact" else None'
name="type" value="contact" checked="checked"/>Contact
</label>
Expand All @@ -46,7 +53,7 @@
name="type" value="delivery"/>Shipping address
</label>
<label class="radio-inline">
<input type="radio" id="radio212_other"
<input type="radio" id="radio212_other"
t-att-checked='"checked" if contact["type"] == "other" else None'
name="type" value="other"/>Other address
</label>
Expand All @@ -64,50 +71,53 @@
t-att-value='contact["street"]' class="form-control"
placeholder="Street..."/>
</div>
<div class="col-sm-4">
<div class="col-sm-5">
<input id="street2" name="street2" type="text"
t-att-value='contact["street2"]' class="form-control"
placeholder="Street2..."/>
</div>
</div>
<div class="form-group">
<label for="address" class="col-sm-3"/>
<div class="col-sm-5">
<label for="address" class="col-form-label">City</label>
<input id="city" name="city" type="text"
t-att-value='contact["city"]' class="form-control"
placeholder="city..."/>
</div>
<div class="col-sm-4">
<div class="col-sm-5">
<label for="address" class="col-form-label">Zip</label>
<input id="zip" name="zip" type="text"
t-att-value='contact["zip"]' class="form-control"
placeholder="zip..."/>
</div>
</div>
<div class="form-group">
<label for="address" class="col-sm-3"/>
<div class="col-sm-5">
<select placeholder="State" name="state_id" class="form-control">
<option value="">State...</option>
<t t-foreach="state_id or []" t-as="state">
<option t-att-value="state.id"
t-att-selected='"selected" if state.id == contact["state_id"]["id"] else ""'>
<t t-esc="state.name"/>
</option>
</t>
</select>
</div>
<div class="col-sm-4">
<label class="col-form-label" for="country_id">Country</label>
<select placeholder="Country" name="country_id" class="form-control">
<option value="">Country...</option>
<t t-foreach="country_id or []" t-as="country">
<option t-att-value="country.id"
t-att-selected='"selected" if country.id == contact["country_id"]["id"] else ""'>
t-att-selected='country.id == contact["country_id"]["id"]'>
<t t-esc="country.name"/>
</option>
</t>
</select>
</div>
<div class="col-sm-5">
<label class="col-form-label" for="state_id">State / Province</label>
<select placeholder="State" name="state_id" class="form-control">
<option value="">State...</option>
<t t-foreach="state_id or []" t-as="state">
<option t-att-value="state.id"
t-att-selected='state.id == contact["state_id"]["id"]'>
<t t-esc="state.name"/>
</option>
</t>
</select>
</div>
</div>

</div>
</xpath>
</template>
Expand Down

0 comments on commit 0109550

Please sign in to comment.