Skip to content

Commit

Permalink
Fix ChoiceFieldMaskType inside CollectionType with inline table setti…
Browse files Browse the repository at this point in the history
…ng (#8100)
  • Loading branch information
nhung-le authored Sep 21, 2023
1 parent 5de1ab0 commit c84e9fd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Resources/views/Form/form_admin_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,38 @@ file that was distributed with this source code.
defaultFieldId = '#{{ main_form_name }}_' + field;
}
// catch select2 fields with inline: table option
if (jQuery(defaultFieldId).length === 0) {
defaultFieldId = '#{{ main_form_name }}_' + field + '_autocomplete_input';
}
return defaultFieldId;
};
jQuery.each(allFields, function (i, field) {
var fieldContainer = controlGroupIdFunc(field);
jQuery(fieldContainer).hide();
{% if form.parent.vars.sonata_admin.inline == 'table' %}
var td = jQuery(fieldContainer).parent();
var columnIndex = td.index();
var headerTh = $("table thead tr th:eq(" + columnIndex + ")");
td.hide();
headerTh.hide();
{% endif %}
jQuery(fieldContainer).find('[required="required"]').attr('data-required', 'required').removeAttr("required");
});
if (map[val]) {
jQuery.each(map[val], function (i, field) {
var fieldContainer = controlGroupIdFunc(field);
jQuery(fieldContainer).show();
{% if form.parent.vars.sonata_admin.inline == 'table' %}
var td = jQuery(fieldContainer).parent();
var columnIndex = td.index();
var headerTh = $("table thead tr th:eq(" + columnIndex + ")");
td.show();
headerTh.show();
{% endif %}
jQuery(fieldContainer).find('[data-required="required"]').attr("required", "required");
});
}
Expand Down

0 comments on commit c84e9fd

Please sign in to comment.