{% set form = _args.form %}
{% set picker = _args.picker is defined ? _args.picker : null %}
{% form_theme form 'form_div_layout.html.twig' %}
<div class="send-msg-radio-grp">
<div class="send-msg-radio-grp__block container-md">
<ul class="inline__list radiolist">
{% for child in form.children %}
<li class="msg-send-input-block">
<span class="custom-control custom-radio">
{{ form_widget(child, {
attr: {
class: 'custom-control-input',
},
}) }}
{{ form_label(child, null, {
label_attr: {
class: 'custom-control-label',
},
}) }}
</span>
</li>
{% endfor %}
{% if picker %}
<li class="schedule-msg-datepicker-block {% if form.vars.data is same as(true) %}is-checked{% endif %}">
{{ form_widget(picker) }}
</li>
{% endif %}
</ul>
</div>
</div>
<script>
$(function () {
$('body').on('change', 'input:radio[name="{{ form.vars.full_name }}"]', function (e) {
var $target = $(e.currentTarget);
$('#{{ picker.vars.id }}').closest('li').toggleClass('is-checked', $target.val());
const $btn = $('#modal__send .crmsg__btngroup');
const $title = $('#modal__send .crmsg__title')
if ($target.val() === '1') {
$('a[data-target="#modal__send"]').text('Schedule');
$btn.html($btn.html().replace('Send', 'Schedule'));
$title.html($title.html().replace('send', 'schedule'));
} else {
$('a[data-target="#modal__send"]').text('Send');
$btn.html($btn.html().replace('Schedule', 'Send'));
$title.html($title.html().replace('schedule', 'send'));
}
});
});
</script>