mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-09 16:24:59 +00:00
[address] allow to add custom data on addresses
This commit is contained in:
@@ -19,6 +19,9 @@ Chill\MainBundle\Entity\Address:
|
||||
isNoAddress:
|
||||
type: boolean
|
||||
default: false
|
||||
customs:
|
||||
type: json
|
||||
default: []
|
||||
manyToOne:
|
||||
postcode:
|
||||
targetEntity: Chill\MainBundle\Entity\PostalCode
|
||||
|
@@ -29,4 +29,10 @@ services:
|
||||
|
||||
Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension:
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
- { name: twig.extension }
|
||||
|
||||
Chill\MainBundle\Templating\Entity\AddressRendering:
|
||||
arguments:
|
||||
$twig: '@templating.engine.twig'
|
||||
tags:
|
||||
- { name: 'chill.render_entity' }
|
@@ -1,20 +1,5 @@
|
||||
{%- macro _render(address, options) -%}
|
||||
{{ address|chill_entity_render_box( options|default({}) ) }}
|
||||
{%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%}
|
||||
{%- set options = { 'has_no_address' : false }|merge(options|default({})) -%}
|
||||
<div class="chill_address">
|
||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
||||
{% endif %}
|
||||
<div class="chill_address_address">
|
||||
{% if address.streetAddress1 is not empty %}<p class="street street1">{{ address.streetAddress1 }}</p>{% endif %}
|
||||
{% if address.streetAddress2 is not empty %}<p class="street street2">{{ address.streetAddress2 }}</p>{% endif %}
|
||||
{% 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="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- if options['with_valid_from'] == true -%}
|
||||
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|localizeddate('long', 'none') } ) }}</span>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
19
Resources/views/Address/render_box_address.html.twig
Normal file
19
Resources/views/Address/render_box_address.html.twig
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="chill_address">
|
||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
||||
{% endif %}
|
||||
<div class="chill_address_address">
|
||||
{% if address.streetAddress1 is not empty %}<p class="street street1">{{ address.streetAddress1 }}</p>{% endif %}
|
||||
{% if address.streetAddress2 is not empty %}<p class="street street2">{{ address.streetAddress2 }}</p>{% endif %}
|
||||
{% 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="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- if options['with_valid_from'] == true -%}
|
||||
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|localizeddate('long', 'none') } ) }}</span>
|
||||
{%- endif -%}
|
||||
{% for k,v in address.customs %}
|
||||
<strong>{{ ('address.customs.' ~ k)|trans }} :</strong> {{ v }}
|
||||
{% endfor %}
|
||||
</div>
|
@@ -182,4 +182,14 @@
|
||||
<button class="chill-collection__button--add sc-button" data-collection-add-target="{{ form.vars.name|escape('html_attr') }}" data-form-prototype="{{ ('<div>' ~ form_widget(form.vars.prototype) ~ '</div>')|escape('html_attr') }}" >{{ form.vars.button_add_label|trans }}</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block address_widget %}
|
||||
{% for entry in form %}
|
||||
{% if entry.vars.name != 'customs' %}
|
||||
{{ form_row(entry) }}
|
||||
{% else %}
|
||||
{{ form_widget(entry) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user