КОНТРОЛЫ/budget.md
Исходный код
Twig код
{% set visual_class_name = 'js-control-pretty-price js-form-changes-skip ' ~ class_name %}
{% set visual_value = value|price([true, value != value|round ? 2 : 0, false, currency])|trim %}
{% if not keep_zero and value == 0 %}
{% set visual_value = '' %}
{% endif %}
{% if additional_data is not defined %}
{% set additional_data = '' %}
{% endif %}
{% if autosized is not defined or autosized == true %}
{% set additional_data = additional_data ~ ' data-autosized="y"' %}
{% endif %}
{% if allow_zero %}
{% set additional_data = additional_data ~ ' data-allow-zero="y"' %}
{% endif %}
{% if not short %}
{% set currency_symbol_helper = '1'|price([false, 0, false, currency]) %}
{#
если после приведения первого символа к инту
там не 0, значит цифры стоят не на перво месте
#}
{% set currency_symbol_first = currency_symbol_helper[0:1]|number_format(0) == 0 %}
{#
заменим в строке 1 (мы ее выше получили форматированием)
на пустоту и обрежем пробелы по краям, тем самым
получим символы валюты
#}
{% set currency_symbol_extracted = currency_symbol_helper|replace({'1': ''})|trim %}
{% else %}
{% set additional_data = additional_data ~ ' data-format-short="1"' %}
{% endif %}
{% set additional_currency_data = currency is defined ? 'data-currency="' ~ currency ~ '"' : '' %}
<div class="control-price {{ wrapper_class_name }}" {{ additional_currency_data|raw }}>
{{ not short and currency_symbol_first ? currency_symbol_extracted|default('') : '' }}
{% include "interface/controls/input.twig" with {
class_name: visual_class_name,
name: '',
value: visual_value,
additional_data: additional_data
} %}
<span class="currency-symbol">
{{ not short and not currency_symbol_first ? currency_symbol_extracted|default('') : '' }}
</span>
{% include "interface/controls/input.twig" with {
class_name: 'js-control-raw-price',
type: 'hidden',
name: name,
value: not keep_zero and value == 0 ? '': value
} only %}
</div>
Ссылка на вики репозиторий
- Страницы
- add_button
- budget
- button
- cancel_button
- chained_list
- checkbox
- checkboxes_dropdown
- checkboxes_dropdown_single
- checkboxes_string
- color_picker
- contenteditable
- date_field
- date_filter
- date_time_field
- deadline_select
- delete_button
- drive_field
- feed_note_main_buttons
- file
- input
- legal_entity
- line_toggler
- multiselect
- payer
- phone
- pipeline_toggler
- radio
- responsive_toggler
- select
- select_with_subtext
- smart_address
- status_chat
- suggest
- supplier
- switcher
- tags
- textarea
- textarea_code
- time
- time_field
- toggler
- updater
- users
- wysiwyg
Ссылка на вики репозиторий
- add_button
- budget
- button
- cancel_button
- chained_list
- checkbox
- checkboxes_dropdown
- checkboxes_dropdown_single
- checkboxes_string
- color_picker
- contenteditable
- date_field
- date_filter
- date_time_field
- deadline_select
- delete_button
- drive_field
- feed_note_main_buttons
- file
- input
- legal_entity
- line_toggler
- multiselect
- payer
- phone
- pipeline_toggler
- radio
- responsive_toggler
- select
- select_with_subtext
- smart_address
- status_chat
- suggest
- supplier
- switcher
- tags
- textarea
- textarea_code
- time
- time_field
- toggler
- updater
- users
- wysiwyg