Changes between Version 18 and Version 19 of S3/S3ReusableField
- Timestamp:
- 01/20/14 08:33:43 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3/S3ReusableField
v18 v19 9 9 A '''{{{S3ReusableField}}}''' is to be defined like a normal [http://web2py.com/book/default/chapter/06?search=Field#DAL,-Table,-Field Field] (though outside any '''{{{Table}}}''' definitions): 10 10 11 {{{ 11 {{{#!python 12 12 person_id = S3ReusableField("person_id", db.pr_person, 13 13 sortby = ["first_name", "middle_name", "last_name"], … … 31 31 To use this in a '''{{{Table}}}''' definition, just call the '''{{{S3ReusableField}}}''' object to generate a '''{{{Field}}}''' instance: 32 32 33 {{{ 33 {{{#!python 34 34 resourcename = "mytable" 35 35 tablename = "%s_%s" % (module, resourcename) … … 45 45 You can override the name and any attributes when generating the '''{{{Field}}}''' instance, by just re-specifying them: 46 46 47 {{{ 47 {{{#!python 48 48 resourcename = "mytable" 49 49 tablename = "%s_%s" % (module, resourcename) … … 59 59 To deactivate a '''{{{IS_NULL_OR}}}''' ('''{{{IS_EMPTY_OR}}}''') validator in the '''{{{S3ReusableField}}}''' when generating the '''{{{Field}}}''' instance, you can use the special attribute '''{{{empty}}}''': 60 60 61 {{{ 61 {{{#!python 62 62 resourcename = "mytable" 63 63 tablename = "%s_%s" % (module, resourcename)