Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed May 6, 2019
1 parent c8cde2e commit 578bb78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions pyforms_web/controls/control_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def deserialize(self, data):
def serialize(self):
data = super(ControlAutoComplete,self).serialize()

if self._value==models.fields.NOT_PROVIDED:
self._value = ValueNotSet

if self.multiple:
if self.value is None:
data.update({'value': []})
Expand All @@ -150,13 +153,13 @@ def serialize(self):

queryset = self.queryset
if queryset:
value = self._value if isinstance(self._value, list) else [self._value]
value = [v for v in value if v if v is not None]

if isinstance(value, ValueNotSet):
if isinstance(self._value, ValueNotSet):
items = []
elif value:
queryset = queryset.filter(pk__in=value).distinct()
elif self._value:
values = self._value if isinstance(self._value, list) else [self._value]
values = [v for v in values if v if v is not None]
queryset = queryset.filter(pk__in=values).distinct()
items = [{'name':str(o), 'value':str(o.pk), 'text':str(o)} for o in queryset]
else:
items = []
Expand Down
2 changes: 1 addition & 1 deletion pyforms_web/web/static/pyformsjs/ControlCheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ControlCheckBox extends ControlBase{
html += "<div style='height: 31px' ></div>";
else
html += "<div style='height: 3px' ></div>";
html += `<div class='ui ${this.properties.checkbox_type} checkbox' title='"+this.properties.help+"' >`;
html += `<div class='ui ${this.properties.checkbox_type} checkbox' title='${this.properties.help}' >`;
html += "<input name='"+this.name+"' id='"+this.control_id()+"' type='checkbox' value='true' class='hidden' />";
html += "<label for='"+this.control_id()+"'>"+this.properties.label+"</label>";
html += "</div></div>";
Expand Down

0 comments on commit 578bb78

Please sign in to comment.