Jump to content

Namedset field: Difference between revisions

From EPrints Documentation
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{reference}}
{{fieldtypes}}
{{fieldtypes}}


== Inherritance ==


* [[Metadata]]
== Description ==
** [[Set field]]
This field allows 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. 
*** [[Namedset field]]


== Description ==
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.


== Properties ==
== Inheritance ==
* [[Metadata]]
** [[Id field]]
*** [[Text field]]
**** [[Set field]]
***** [[Namedset field]]


As for [[set field]]s with the following differences...
== Additional Properties ==
As for [[Set field#Additional_Properties|Set fields]] except for:


{| border="1" cellpadding="3" cellspacing="0"
{| border="1" cellpadding="3" cellspacing="0"
| name || default || description
! Name !! Default Value !! Required !! Description !! Notes
|-
|-
| '''set_name''' || n/a/ || '''This property is always required.'''
| '''set_name''' || n/a || YES || Specifies the filename of the namedset file. ||
|-
|-
| '''options''' || undef || ...
| '''options''' || <tt>undef</tt> || NO || Options from which to choose. || NOT inherited from [[Set field]]. Options provided by namedset file defined in <tt>set_name</tt>.
|}
|}


== Required Phrases ==
== Required Phrases ==
No additional phrases beyond those required for [[Set field#Required_Phrases|Set fields]].  However, you may need to add phrases for some or 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'
}

Latest revision as of 11:02, 16 April 2023


Description[edit]

This field allows 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[edit]

Additional Properties[edit]

As for Set fields except for:

Name Default Value Required Description Notes
set_name n/a YES Specifies the filename of the namedset file.
options undef NO Options from which to choose. NOT inherited from Set field. Options provided by namedset file defined in set_name.

Required Phrases[edit]

No additional phrases beyond those required for Set fields. However, you may need to add phrases for some or 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[edit]

Namedset fields are stored in the database as

fieldname VARCHAR(255)

API[edit]

See API page.

Examples[edit]

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'
}