Here is a simple fix if there hasn't been one added to Web2Py yet. Use the
Bootstrap readonly attribute.
example:
form.element('input', _id='RentalTransactionMaster_TotalAmt')['_readonly']=''
Placed in controller after the form = SQLFORM(...) declaration.
On Friday, March 31, 2017 at
Right. I think I didn't run into that issue because the original values in
the updated record already satisfied the validation criteria.
Note, there was another problem with the solution allowing a malicious user
to pass back altered values for the readonly fields, so I updated the code
to an
Hi Anthony --
After some digging, I think I understand the flow and why this is required.
When the form is built, one of the byproducts is to create a widget for
each field and preset that widget with the information it needs to do
validation (i.e. the 'requires' of the field is copied to the
On Friday, March 31, 2017 at 5:41:49 PM UTC-4, Joe Barnhart wrote:
>
> Anthony --
>
> One more tiny but not insignificant detail...
>
> I found I had to add "requires=[]" to the custom.widget:
>
> [form.custom.widget[f.name].update(_readonly=True, requires=[]) for f
> in readonly_fields]
>
>
Anthony --
One more tiny but not insignificant detail...
I found I had to add "requires=[]" to the custom.widget:
[form.custom.widget[f.name].update(_readonly=True, requires=[]) for f in
readonly_fields]
Otherwise, the field keeps the 'requires' of the original Field and the
check fails.
You are a frickin' genius.
Here are some epiphanies I got from your solution:
1. SQLFORM builds the XML components of the forms immediately. I didn't
know if that was deferred or immediate. Now I know.
2. form.custom.widgets allows access to each XML widget in a dictionary.
We can screw
You can also change the "represent" attribute of readonly fields so they
are wrapped in a div with a special class, and then use CSS to style that
class to your liking.
Anthony
On Friday, March 31, 2017 at 11:49:51 AM UTC-4, Anthony wrote:
>
> We should probably make what you are doing a
We should probably make what you are doing a built-in option (maybe even
the default), but for now, you can try something like this:
def sqlform2(*args, **kwargs):
table = kwargs.get('table', args[0])
fields = kwargs.get('fields', [f for f in table])
readonly_fields = [f for f in
On Friday, March 31, 2017 at 7:54:32 AM UTC-4, 黄祥 wrote:
>
> had you try widgets?
> e.g.
> widget_date_disable = lambda field, value: \
> SQLFORM.widgets.date.widget(field, value,
> _disable = True,
> _class = "date form-control")
>
For that to work, you have to leave writable=True, which would
had you try widgets?
e.g.
widget_date_disable = lambda field, value: \
SQLFORM.widgets.date.widget(field, value,
_disable = True,
_class = "date form-control")
best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py
10 matches
Mail list logo