Uncorrect adding of ng attributes for MultiWidget
Closed this issue · 5 comments
vivazzi commented
For example, I want to filter products by price using django-filters:
class FilterForm(NgModelFormMixin, Bootstrap3Form):
def __init__(self, *args, **kwargs):
kwargs.update({'scope_prefix': 'filters',
'ng_change': 'filterChanged()'})
super(FilterForm, self).__init__(*args, **kwargs)
class CustomFilterSet(django_filters.FilterSet):
...
unit_price = django_filters.RangeFilter(label='From - To', name='unit_price')
class Meta:
model = Product
form = FilterForm
fields = ('unit_price', )
@classmethod
def get_render_context(cls, request, queryset):
filter_set = cls(data=request.GET)
...
return dict(filter_set=filter_set)
I get html:
<label for="id_unit_price">From - To</label>
<input class="form-control ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched" id="id_unit_price_0" name="unit_price_0" ng-change="filterChanged()" ng-model="filters['unit_price']" type="text" style="">
-
<input class="form-control ng-pristine ng-valid ng-not-empty ng-touched" id="id_unit_price_1" name="unit_price_1" ng-change="filterChanged()" ng-model="filters['unit_price']" type="text" style="">
Although, I should get:
<label for="id_unit_price">From - To</label>
<input class="form-control ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched" id="id_unit_price_0" name="unit_price_0" ng-change="filterChanged()" ng-model="filters['unit_price_0']" type="text" style="">
-
<input class="form-control ng-pristine ng-valid ng-not-empty ng-touched" id="id_unit_price_1" name="unit_price_1" ng-change="filterChanged()" ng-model="filters['unit_price_1']" type="text" style="">
i. e. ng-model instead of ng-model="filters['unit_price']"
should be ng-model="filters['unit_price_0']"
for first input and ng-model="filters['unit_price_1']"
for second input.
adrienbrunet commented
Correct. this is the second time this issue is reported (Issue #288 ) . Support for MultipleValueField may need some more work. Would you like to investigate?
vivazzi commented
@adrienbrunet I am glad to help! I will try it in May (now I'm busy). I will do pull request as soon as I can.
jrief commented
closing for inactivity