update twig template and AddressType following the changes in Address entity

This commit is contained in:
nobohan 2021-04-23 16:48:27 +02:00
parent ebff36d257
commit 05d3d7f5c7
5 changed files with 32 additions and 32 deletions

View File

@ -367,12 +367,12 @@ class Address
return $this; return $this;
} }
public function getNumber(): ?string public function getStreetNumber(): ?string
{ {
return $this->streetNumber; return $this->streetNumber;
} }
public function setNumber(string $streetNumber): self public function setStreetNumber(string $streetNumber): self
{ {
$this->streetNumber = $streetNumber; $this->streetNumber = $streetNumber;

View File

@ -33,8 +33,8 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
* A type to create/update Address entity * A type to create/update Address entity
* *
* Options: * Options:
* *
* - `has_valid_from` (boolean): show if an entry "has valid from" must be * - `has_valid_from` (boolean): show if an entry "has valid from" must be
* shown. * shown.
* - `null_if_empty` (boolean): replace the address type by null if the street * - `null_if_empty` (boolean): replace the address type by null if the street
* or the postCode is empty. This is useful when the address is not required and * or the postCode is empty. This is useful when the address is not required and
@ -45,10 +45,10 @@ class AddressType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('streetAddress1', TextType::class, array( ->add('street', TextType::class, array(
'required' => !$options['has_no_address'] // true if has no address is false 'required' => !$options['has_no_address'] // true if has no address is false
)) ))
->add('streetAddress2', TextType::class, array( ->add('streetNumber', TextType::class, array(
'required' => false 'required' => false
)) ))
->add('postCode', PostalCodeType::class, array( ->add('postCode', PostalCodeType::class, array(
@ -57,7 +57,7 @@ class AddressType extends AbstractType
'required' => !$options['has_no_address'] // true if has no address is false 'required' => !$options['has_no_address'] // true if has no address is false
)) ))
; ;
if ($options['has_valid_from']) { if ($options['has_valid_from']) {
$builder $builder
->add('validFrom', DateType::class, array( ->add('validFrom', DateType::class, array(
@ -67,7 +67,7 @@ class AddressType extends AbstractType
) )
); );
} }
if ($options['has_no_address']) { if ($options['has_no_address']) {
$builder $builder
->add('isNoAddress', ChoiceType::class, [ ->add('isNoAddress', ChoiceType::class, [
@ -79,12 +79,12 @@ class AddressType extends AbstractType
'label' => 'address.address_homeless' 'label' => 'address.address_homeless'
]); ]);
} }
if ($options['null_if_empty'] === TRUE) { if ($options['null_if_empty'] === TRUE) {
$builder->setDataMapper(new AddressDataMapper()); $builder->setDataMapper(new AddressDataMapper());
} }
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver $resolver

View File

@ -6,8 +6,8 @@
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div> <div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
{% endif %} {% endif %}
<div class="chill_address_address"> <div class="chill_address_address">
{% if address.streetAddress1 is not empty %}<p class="street street1">{{ address.streetAddress1 }}</p>{% endif %} {% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
{% if address.streetAddress2 is not empty %}<p class="street street2">{{ address.streetAddress2 }}</p>{% endif %} {% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
{% if address.postCode is not empty %} {% if address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p> <p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p> <p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>

View File

@ -21,17 +21,17 @@
{% block title 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) %} {% block title 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) %}
{% block personcontent %} {% block personcontent %}
<h1>{{ 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1> <h1>{{ 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_row(form.isNoAddress) }} {{ form_row(form.isNoAddress) }}
{{ form_row(form.streetAddress1) }} {{ form_row(form.street) }}
{{ form_row(form.streetAddress2) }} {{ form_row(form.streetNumber) }}
{{ form_row(form.postCode) }} {{ form_row(form.postCode) }}
{{ form_row(form.validFrom) }} {{ form_row(form.validFrom) }}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button bt-cancel"> <a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button bt-cancel">
@ -42,7 +42,7 @@
{{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-save' }, 'label': 'Save' } ) }} {{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-save' }, 'label': 'Save' } ) }}
</li> </li>
</ul> </ul>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock personcontent %} {% endblock personcontent %}

View File

@ -21,21 +21,21 @@
{% block title %}{{ 'New address for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %} {% block title %}{{ 'New address for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
{% block personcontent %} {% block personcontent %}
<h1>{{ 'New address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1> <h1>{{ 'New address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_row(form.isNoAddress) }} {{ form_row(form.isNoAddress) }}
{{ form_row(form.streetAddress1) }} {{ form_row(form.street) }}
{{ form_errors(form.streetAddress1) }} {{ form_errors(form.street) }}
{{ form_row(form.streetAddress2) }} {{ form_row(form.streetNumber) }}
{{ form_errors(form.streetAddress2) }} {{ form_errors(form.streetNumber) }}
{{ form_row(form.postCode) }} {{ form_row(form.postCode) }}
{{ form_errors(form.postCode) }} {{ form_errors(form.postCode) }}
{{ form_row(form.validFrom) }} {{ form_row(form.validFrom) }}
{{ form_errors(form.validFrom) }} {{ form_errors(form.validFrom) }}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button bt-cancel"> <a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button bt-cancel">
@ -46,7 +46,7 @@
{{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-create' }, 'label': 'Create' } ) }} {{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-create' }, 'label': 'Create' } ) }}
</li> </li>
</ul> </ul>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock personcontent %} {% endblock personcontent %}