Commit c19459ed authored by droces's avatar droces

For booking form, Addons field, if there are no checkboxes, make them from fetched data

parent a5cc826b
......@@ -280,6 +280,27 @@ function add_booking_data_fetched_listener() {
// Hide all the addons
var addon_checkboxes = $('input[name^="field_addons"]');
// If there are no checkboxes, make them from fetched data
if (addon_checkboxes.length == 0) {
$.each(bookable_data['addons'], function(index, addon_data) {
// console.log('addon_data: ', addon_data);
var checkbox = $('<div class="form-item form-type-checkbox" style="display: block;"></div>')
.append('<input id="edit-field-addons-' + addon_data.nid + '" '
+ 'name="field_addons[' + addon_data.nid + ']" '
+ 'value="' + addon_data.nid + '" '
+ 'class="form-checkbox" type="checkbox">')
.append('<label for="edit-field-addons-' + addon_data.nid + '" '
+ 'class="option">Cottage</label>');
$('.field--name-field-addons .form-checkboxes').append(checkbox);
});
addon_checkboxes = $('input[name^="field_addons"]');
// console.log('addon_checkboxes: ', addon_checkboxes);
}
addon_checkboxes.parents('.form-type-checkbox').hide();
// For all addons the selected bookable has, show them, append cost
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment