fix bug when postal code is null + add validation for address &postcode

fix #20
fix #18
This commit is contained in:
Julien Fastré 2016-03-18 11:49:56 +01:00
parent 4a77d7617a
commit 386d4dd623
4 changed files with 31 additions and 1 deletions

View File

@ -42,7 +42,9 @@ class AddressType extends AbstractType
'required' => false
))
->add('postCode', PostalCodeType::class, array(
'label' => 'Postal code'
'label' => 'Postal code',
'placeholder' => 'Choose a postal code',
'required' => true
))
->add('validFrom', 'date', array(
'required' => true,

View File

@ -29,3 +29,28 @@ Chill\MainBundle\Entity\Center:
- Length:
max: 50
min: 3
Chill\MainBundle\Entity\Address:
properties:
streetAddress1:
- Length:
min: 2
max: 250
postcode:
- NotNull: ~
validFrom:
- NotNull: ~
- Date: ~
Chill\MainBundle\Entity\PostalCode:
properties:
name:
- Length:
max: 250
min: 2
code:
- Length:
min: 2
max: 100
country:
- NotNull: ~

View File

@ -27,6 +27,7 @@ Street address1: Adresse ligne 1
Street address2: Adresse ligne 2
Postal code: Code postal
Valid from: Valide à partir du
Choose a postal code: Choisir un code postal
#serach
Your search is empty. Please provide search terms.: La recherche est vide. Merci de fournir des termes de recherche.

View File

@ -2,8 +2,10 @@
{% set options = { 'with_valid_from' : true }|merge(options|default({})) %}
{% if address.streetAddress1 is not empty %}<span class="street street1">{{ address.streetAddress1 }}</span><br/>{% endif %}
{% if address.streetAddress2 is not empty %}<span class="street street2">{{ address.streetAddress2 }}</span><br/>{% endif %}
{% if address.postCode is not empty %}
<span class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></span><br/>
<span class="country">{{ address.postCode.country.name|localize_translatable_string }}</span><br/>
{% endif %}
{%- if options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|localizeddate('long', 'none') } ) }}</span>
{%- endif -%}