This would be the code to override all the widgets (the list widgets are 
missing) for bootstrap3.

http://pastebin.com/LJzhXvnh

I know it is JS but it is really not mad and much more user friendly than 
the code in sqlhtml.py.

Massimo


On Monday, 8 September 2014 23:43:31 UTC-5, Massimo Di Pierro wrote:
>
> This is what the plain TextWidget looks now in Python:
>
> class TextWidget(FormWidget):
>     _class = 'text'
>     @classmethod
>     def widget(cls, field, value, **attributes):
>         default = dict(value=value)
>         attr = cls._attributes(field, default, **attributes)
>         return TEXTAREA(**attr)
>
> This is the corresponding JS one optimized for bootstrap 3:
>
>     jform.widgets['text'] = function(field) { return 
> jform.tag('textarea',{'name':field.name
> ,'class':'form-control'})(field.value); }
>
> Did you notice how simpler it is? I think most Python programmers will 
> prefer the latter to the former.
> Also notice I have already ported the web2py helpers to JS. 
>
>      jfom.tag('textarea', attributes)(field.value) 
>
> is the same as web2py's 
>
>     TEXTAREA(field.value,**attributes)
>
> Massimo
>
>
> On Monday, 8 September 2014 16:51:54 UTC-5, Andrew W wrote:
>>
>> Sounds like I need to improve my JS skills.
>> A Plugin or a Module ?   which is better for this type of thing ?
>>
>>
>>
>> On Friday, September 5, 2014 3:56:23 PM UTC+10, Massimo Di Pierro wrote:
>>>
>>> Please find attached a welcome4.zip with contains the following files:
>>>
>>> controllers/default.py
>>> views/layout.html
>>> vides/default/index.html
>>> modules/jform.py
>>> static/js/jform.js
>>> static/js/jform-bootstrap2.js
>>> static/js/jform-bootstrap3.js
>>>
>>> My proposal is the following:
>>> 1) deprecate SQLFORM (but keep it for backward compatibility)
>>> 2) replace 
>>>
>>>     form = SQLFORM(table).process()
>>>     ...
>>>     {{=form}}
>>>
>>> with
>>>   
>>>     form = JForm(table)
>>>     ...
>>>     {{=form}}
>>>
>>> what is the difference? SQLFORM generates html. JForm generates JSON 
>>> metadata which is then converted into the form client-side by the js in 
>>> jform.js.
>>> why?
>>> - it is much faster because all rendering is done client-side
>>> - it can "optionally" submit the form via Ajax without having to change 
>>> your code.
>>> - it is much easier to style and create widgets for different css 
>>> frameworks.
>>> For example include the right one:
>>> static/js/jform-bootstrap2.js
>>> static/js/jform-bootstrap3.js (I only provide a layout for bs2 and not 
>>> bs3)
>>> - it is much more powerful because you can customize widgets in JS. 
>>>
>>> We could also add a JTable, a JMenu and a JLogin and keep all the 
>>> styling info in JS files as opposed to Python files.
>>> This would make web2py leaner and cleaner.
>>>
>>> Thoughts?
>>>
>>> Massimo
>>>
>>>
>>>
>>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to