Changes between Version 22 and Version 23 of DeveloperGuidelinesS3Framework
- Timestamp:
- 05/20/09 20:56:58 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelinesS3Framework
v22 v23 53 53 List output are made more functional by this .represent 'widget': 54 54 {{{ 55 def shn_list_item(table, resource,action,display='table.name',extra=None):55 def shn_list_item(table, resource, action, display='table.name', extra=None): 56 56 if extra: 57 items =DIV(TR(TD(A(eval(display),_href=t2.action(resource,[action,table.id]))),TD(eval(extra))))57 items = DIV(TR(TD(A(eval(display), _href=t2.action(resource, [action, table.id]))), TD(eval(extra)))) 58 58 else: 59 items =DIV(A(eval(display),_href=t2.action(resource,[action,table.id])))59 items = DIV(A(eval(display), _href=t2.action(resource, [action, table.id]))) 60 60 return DIV(*items) 61 61 }}} 62 62 This is called in {{{models/__db.py}}} in the RESTlike Controller: 63 63 {{{ 64 db.person.represent =lambda table:shn_list_item(table,resource='person',action='display',display='table.full_name')64 db.person.represent = lambda table:shn_list_item(table, resource='person', action='display', display='table.full_name') 65 65 }}} 66 66 67 67 Form labels can be set in a translatable manner using: 68 {{{db.table.field.label =T("label")}}}68 {{{db.table.field.label = T("label")}}} 69 69 70 70 Form field can be made to use a TEXTAREA by marking the field as being type 'text': 71 {{{db.Field('field', 'text'),}}}71 {{{db.Field('field', 'text'),}}} 72 72 73 73 Form field can be made to use a SELECT dropdown by setting the field as a lookup to another table...linked to the 'id' field to allow [wiki:DeveloperGuidelinesDatabaseSynchronization Database Synchronization], but displaying a more user-friendly field (such as 'name'): 74 74 {{{ 75 db.Field('field', db.othertable),75 db.Field('field', db.othertable), 76 76 77 db.table.field.requires =IS_NULL_OR(IS_IN_DB(db,'othertable.id','othertable.name'))77 db.table.field.requires = IS_NULL_OR(IS_IN_DB(db, 'othertable.id', 'othertable.name')) 78 78 }}} 79 79 80 80 Form field being required can be marked using: 81 {{{db.table.field.comment =SPAN("*",_class="req")}}}81 {{{db.table.field.comment = SPAN("*", _class="req")}}} 82 82 83 83 Help for a form field can be set using: 84 {{{A(SPAN("[Help]"), _class="tooltip",_title=T("Help Title|This is what this <a href='http://wikipedia.org/Field' target=_blank>field</a> is for."))}}}84 {{{A(SPAN("[Help]"), _class="tooltip", _title=T("Help Title|This is what this <a href='http://wikipedia.org/Field' target=_blank>field</a> is for."))}}} 85 85 86 86 Different Flash styles can be set via: 87 87 {{{ 88 session.error =T("Unsupported format!")89 redirect(URL(r=request, f=resource))88 session.error = T("Unsupported format!") 89 redirect(URL(r=request, f=resource)) 90 90 }}} 91 91 or (in a Multiple Table form.accepts): 92 92 {{{ 93 response.error =T("Form invalid!")93 response.error = T("Form invalid!") 94 94 }}} 95 95 Supported styles are: … … 105 105 106 106 If these settings are required by all Views then can patch the session to see them in {{{models/_db.py}}}'s {{{shn_sessions()}}}.[[BR]] 107 e.g. session.s3.debug & session.s3.self_registration aremade available to the default {{{layout.html}}} this way.107 e.g. session.s3.debug is made available to the default {{{layout.html}}} this way. 108 108 109 109 If you wish to clean out all settings to import afresh, then close down Web2Py & delete all files from {{{/databases}}})