Skip to content

Commit

Permalink
Add checkbox_type parameter to ControlCheckBox
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Apr 4, 2019
1 parent e672772 commit eb779af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion pyforms_web/controls/control_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ class ControlCheckBox(ControlBase):

def __init__(self, *args, **kwargs):
if 'default' not in kwargs: kwargs['default']=False
self.checkbox_type = kwargs.get('checkbox_type', 'toggle')

super().__init__(*args, **kwargs)


def init_form(self): return "new ControlCheckBox('{0}', {1})".format( self._name, simplejson.dumps(self.serialize()) )
def init_form(self):
return "new ControlCheckBox('{0}', {1})".format( self._name, simplejson.dumps(self.serialize()) )

def serialize(self):
res = super().serialize()
res['checkbox_type'] = self.checkbox_type
return res
6 changes: 3 additions & 3 deletions pyforms_web/web/static/pyforms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 toggle 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 eb779af

Please sign in to comment.