| 15 | |
| 16 | == Example == |
| 17 | |
| 18 | This package allows Plone developers to: |
| 19 | |
| 20 | * extend default Plone Reference field functionality |
| 21 | * override existing Reference field functionality with a custom one |
| 22 | |
| 23 | There is an example of simple content type creation with a mix of Reference and !DataGrid fields as related items: |
| 24 | http://svn.plone.org/svn/collective/collective.referencedatagridfield/collective/referencedatagridfield/examples/ReferenceDataGridDemoType.py |
| 25 | |
| 26 | {{{ |
| 27 | from AccessControl import ClassSecurityInfo |
| 28 | |
| 29 | from Products.Archetypes.public import * |
| 30 | from Products.ATContentTypes.content.base import ATCTContent |
| 31 | |
| 32 | |
| 33 | from collective.referencedatagridfield import PKG_NAME |
| 34 | from collective.referencedatagridfield import ReferenceDataGridField |
| 35 | from collective.referencedatagridfield import ReferenceDataGridWidget |
| 36 | |
| 37 | class ReferenceDataGridDemoType(ATCTContent): |
| 38 | """ Simple ReferenceDataGridField demo.""" |
| 39 | security = ClassSecurityInfo() |
| 40 | schema = BaseSchema + Schema(( |
| 41 | |
| 42 | ReferenceDataGridField('demo_rdgf', |
| 43 | schemata='default', |
| 44 | relationship="demo_relation", |
| 45 | widget = ReferenceDataGridWidget( |
| 46 | label = "Reference DataGrid Field(s)", |
| 47 | visible = {'edit' : 'visible', 'view' : 'visible'} |
| 48 | ) |
| 49 | ), |
| 50 | )) |
| 51 | |
| 52 | meta_type = portal_type = archetype_name = 'ReferenceDataGridDemoType' |
| 53 | |
| 54 | registerType(ReferenceDataGridDemoType, PKG_NAME) |
| 55 | |
| 56 | }}} |