Difference between revisions of "Namedset field"
(Added examples. Improved other sections unhide ToC.) |
|||
Line 1: | Line 1: | ||
{{fieldtypes}} | {{fieldtypes}} | ||
− | + | ||
+ | |||
+ | == Description == | ||
+ | This field allow a choice from a set of options like a [[Set field]]. However, here the options can be defined within a namedset file rather than under the <tt>options></tt> attribute of the field configuration. This makes it easier to update the available options, potentially programmatically. | ||
+ | |||
+ | This field offers a halfway house between a [[Set field]] and a [[Subject field]]. Being more easily re-configurable that the former whilst less complex than the latter. | ||
+ | |||
== Inheritance == | == Inheritance == | ||
− | |||
* [[Metadata]] | * [[Metadata]] | ||
** [[Set field]] | ** [[Set field]] | ||
*** [[Namedset field]] | *** [[Namedset field]] | ||
− | |||
− | |||
== Properties == | == Properties == | ||
− | |||
As for [[set field]]s with the following differences... | As for [[set field]]s with the following differences... | ||
Line 16: | Line 18: | ||
| name || default || description | | name || default || description | ||
|- | |- | ||
− | | '''set_name''' || n/a | + | | '''set_name''' || n/a || '''Specifies the filename of the namedset file. This property is always required.''' |
|- | |- | ||
− | | '''options''' || undef || . | + | | '''options''' || undef || '''This property should not be set as will be overridden by the options in the namedset file specified by <tt>set_name</tt>.''' |
|} | |} | ||
== Required Phrases == | == Required Phrases == | ||
+ | No additional phrases. However, you may need to add phrases for some of all the values on the namedset file, depending on whether this is a bespoke namedset file. These will take the form: | ||
+ | namedset_filename + "_typename_" + value | ||
+ | For example for <tt>[[lib/namedsets/]]</tt>'s <tt>security</tt> file, the phrase for <tt>staffonly</tt> has the ID: | ||
+ | security_typename_staffonly | ||
+ | |||
+ | == Database == | ||
+ | Namedset fields are stored in the database as | ||
+ | fieldname VARCHAR(255) | ||
+ | |||
+ | == API == | ||
+ | See [[API:EPrints/MetaField/Namedset|API page]]. | ||
+ | |||
+ | == Examples == | ||
+ | Most basic example. | ||
+ | { | ||
+ | name => 'archive', | ||
+ | type => 'namedset', | ||
+ | set_name => 'archives', | ||
+ | } | ||
+ | Make field required and only show one input row. | ||
+ | { | ||
+ | name => 'security', | ||
+ | type => 'namedset', | ||
+ | required => 1, | ||
+ | input_rows => 1, | ||
+ | set_name=> 'security', | ||
+ | } | ||
+ | Allow multiple values with long input style (i.e. a list of labelled checkboxes). Link rendered values to a browse view listing. | ||
+ | { | ||
+ | name => 'category', | ||
+ | type => 'namedset', | ||
+ | set_name => 'artwork', | ||
+ | multiple => 1, | ||
+ | required => 1, | ||
+ | input_style => 'long', | ||
+ | browse_link => 'category' | ||
+ | } |
Revision as of 15:01, 30 March 2023
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Metadata Fields: Arclanguage - Base64 - Bigint - Boolean - Compound - Counter - Dataobjref - Date - Decimal - Email - Fields - Float - Id - Idci - Image - Int - Itemref - Keywords - Langid - Longtext - Longtext_counter - Multilang - Multipart - Name - Namedset - Pagerange - Recaptcha - Recaptcha3 - Relation - Search - Secret - Set - Storable - Subject - Subobject - Text - Time - Timestamp - Url - Uuid
Description
This field allow a choice from a set of options like a Set field. However, here the options can be defined within a namedset file rather than under the options> attribute of the field configuration. This makes it easier to update the available options, potentially programmatically.
This field offers a halfway house between a Set field and a Subject field. Being more easily re-configurable that the former whilst less complex than the latter.
Inheritance
Properties
As for set fields with the following differences...
name | default | description |
set_name | n/a | Specifies the filename of the namedset file. This property is always required. |
options | undef | This property should not be set as will be overridden by the options in the namedset file specified by set_name. |
Required Phrases
No additional phrases. However, you may need to add phrases for some of all the values on the namedset file, depending on whether this is a bespoke namedset file. These will take the form:
namedset_filename + "_typename_" + value
For example for lib/namedsets/'s security file, the phrase for staffonly has the ID:
security_typename_staffonly
Database
Namedset fields are stored in the database as
fieldname VARCHAR(255)
API
See API page.
Examples
Most basic example.
{ name => 'archive', type => 'namedset', set_name => 'archives', }
Make field required and only show one input row.
{ name => 'security', type => 'namedset', required => 1, input_rows => 1, set_name=> 'security', }
Allow multiple values with long input style (i.e. a list of labelled checkboxes). Link rendered values to a browse view listing.
{ name => 'category', type => 'namedset', set_name => 'artwork', multiple => 1, required => 1, input_style => 'long', browse_link => 'category' }