Found a solution (more like a kludge) :) form.element('#no_table_sn').attributes['_readonly'] = 'readonly'
I even tried adding _readonly='readonly' to the Field, but didn't work. Only works after the form exists. Is there a better way? sexta-feira, 29 de Março de 2019 às 21:25:48 UTC, João Matos escreveu: > > The field I want to make read-only is sn. > > form = SQLFORM.factory( > Field('equipment_id', > label=T('Equipment'), > requires=IS_IN_DB(db, 'equipment.id', '%(name)s', zero=None > ), > ), > Field('sn', 'integer', label=T('SN'), writable=False), > Field('code', label=T('WO'), requires=IS_EMPTY_OR( > IS_IN_DB(db(query), 'wo.code', distinct=True))), > Field('client_id', > label=T('Client'), > requires=IS_IN_DB(db, 'client.id', '%(name)s', zero=T('Choose > one...')), > ), > Field('manual_lang_id', > label=T('Manual language'), > requires=IS_IN_DB(db, > 'manual_lang.id', > '%(name)s', > zero=T('Choose one...'), > ), > ), > Field('co_code', 'string', default='', label=T('Customer order')), > Field('so_code', 'string', default='', label=T('Supplier order')), > Field('export', 'boolean', default=False, label=T('Export')), > Field('notes', 'string', default='', label=T('Notes')), > Field('observations', 'string', default='', label=T('Observations' > )), > Field('est_finish', 'date', label=T('Estimated finish'), notnull= > True, > required=True, > requires=IS_DATE_IN_RANGE( # format=T('%Y-%m-%d'), > minimum=request.now.date() + > timedelta(days=1), > # maximum=request.now.date() + , > error_message=T('Must be a future > date.') > ) > ), > *factory_fields, > hidden={'mon': wo.modified_on}, > ) > > > > sexta-feira, 29 de Março de 2019 às 21:20:27 UTC, Jim S escreveu: >> >> Can you show some code? Mine is working fine without a db and specifying >> writable=False. >> >> -Jim >> >> On Fri, Mar 29, 2019 at 4:02 PM João Matos <jcrm...@gmail.com> wrote: >> >>> It is readable and editable. >>> >>> -- >>> 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 a topic in the >>> Google Groups "web2py-users" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/web2py/U7zQi02p2MY/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> web...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- 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.