openclassify/addons/default/visiosoft/customfields-module/resources/views/new-ad/other-fields.twig
Mostafa Moradi 4eac3243b8 4.0-mostafa
2024-08-18 17:45:09 +03:00

32 lines
1.6 KiB
Twig

{% for custom_field in custom_fields %}
<div class="{{ custom_field['type'] == 'checkboxes' ? 'col-md-12' : 'col-md-3' }} form-group custom-fields {{ custom_field.type|raw }}_container mx-0 my-4" data-slug="{{ custom_field.custom_field_slug }}">
<label class="label-title {{ custom_field.type|raw }}_title
{{ custom_field['type'] == 'checkboxes' ? 'd-flex justify-content-between align-items-center' }}"
onclick="$(this).hasClass('checkboxes_title') ? $(this).siblings().toggleClass('d-none') : null">
{{ custom_field.custom_field_label|raw }}
{% if custom_field['type'] == 'checkboxes' %}
<i class="fa fa-angle-down"></i>
{% endif %}
</label>
<div class="col-sm-12 {{ custom_field['type'] == 'checkboxes' ? 'd-none' }}">
<div class="{{ custom_field.type|raw }}_data" data-date="{{ custom_field.data_date }}">
{{ custom_field.custom_field_input|raw }}
</div>
</div>
</div>
{% endfor %}
<script>
let date_customfield = $("[data-date=1] input");
if (date_customfield) {
date_customfield.attr('type', 'date');
date_customfield.on('change', () => {
const status = date_customfield.val() > new Date().toISOString().slice(0, 10);
date_customfield.attr('style', !status ? 'border-color: red !important' : '');
$("[name='action']").attr('disabled', !status);
});
}
</script>
{{ asset_add('styles.css','visiosoft.module.customfields::css/fields.css') }}