0001-misc-add-dynamic-change-of-options-to-radio-buttons-.patch
wcs/qommon/static/js/qommon.forms.js | ||
---|---|---|
292 | 292 |
} else { |
293 | 293 |
$widget.hide(); |
294 | 294 |
} |
295 |
if (value.items) { |
|
295 |
if (value.items && $widget.is('.RadiobuttonsWidget')) { |
|
296 |
var current_value = $widget.find('input:checked').val(); |
|
297 |
var $hint = $widget.find('.hint').detach(); |
|
298 |
var input_name = $widget.data('widget-name'); |
|
299 |
var $content = $widget.find('.content'); |
|
300 |
$content.empty(); |
|
301 |
for (var i=0; i<value.items.length; i++) { |
|
302 |
var $label = $('<label></label>'); |
|
303 |
var $input = $('<input>', {type: 'radio', value: value.items[i].id, name: input_name}); |
|
304 |
if (value.items[i].id == current_value) { |
|
305 |
$input.attr('checked', 'checked'); |
|
306 |
} |
|
307 |
var $span = $('<span></span>', {text: value.items[i].text}); |
|
308 |
$input.appendTo($label); |
|
309 |
$span.appendTo($label); |
|
310 |
$label.appendTo($content); |
|
311 |
} |
|
312 |
$hint.appendTo($content); |
|
313 |
} else if (value.items) { |
|
296 | 314 |
// replace <select> contents |
297 | 315 |
var $select = $widget.find('select'); |
298 | 316 |
var current_value = $select.val(); |
wcs/qommon/templates/qommon/forms/widget.html | ||
---|---|---|
5 | 5 |
{% if widget.is_prefilled %}widget-prefilled{% endif %}" |
6 | 6 |
{% if widget.is_hidden %}style="display: none"{% endif %} |
7 | 7 |
{% if widget.field %}data-field-id="{{ widget.field.id }}"{% endif %} |
8 |
data-widget-name="{{ widget.name }}" |
|
8 | 9 |
{% if widget.div_id %}id="{{widget.div_id}}" data-valuecontainerid="form_{{widget.name}}"{% endif %} |
9 | 10 |
{% for attr in widget.prefill_attributes %} |
10 | 11 |
data-{{attr}}="{{widget.prefill_attributes|get:attr}}" |
11 |
- |