Difference between revisions of "Set field"

From EPrints Documentation
Jump to: navigation, search
(Added ToC. Added API and Examples sections. Reorganised/completed other sections.)
Line 1: Line 1:
 
{{fieldtypes}}
 
{{fieldtypes}}
__NOTOC__
+
 
 +
 
 +
== Description ==
 +
Allows a set of options to be specified using the <code>options</code> attribute of the field's configuration.  The set of options is then displayed in one of several different forms:
 +
* radio buttons if <code>input_style => 'long'</code> or <code>input_style => 'medium'</code> and <code>multiple => 0</code>.
 +
* check boxes if <code>input_style => 'long'</code> or <code>input_style => 'medium'</code> and <code>multiple => 1</code>.
 +
* select box if <code>input_style => 'short'</code>.
 +
When <code>input_style => 'long'</code> is used both names and descriptions for each option will be displayed with radio buttons / check boxes.  For <code>input_style => 'medium'</code> only names are displayed.
 +
 
 
== Inheritance ==
 
== Inheritance ==
 
 
* [[Metadata]]
 
* [[Metadata]]
 
** [[Set field]]
 
** [[Set field]]
 
== Description ==
 
  
 
== Properties ==
 
== Properties ==
 
 
{| border="1" cellpadding="3" cellspacing="0"
 
{| border="1" cellpadding="3" cellspacing="0"
 
| name || default || description  
 
| name || default || description  
Line 31: Line 35:
  
 
== Required Phrases ==
 
== Required Phrases ==
 +
If <code>input_style => 'short'</code> or <code>input_style => 'medium'</code> then the only extra phrases required are the name label for each of the options in the form:
 +
datasetid + "_fieldopt_" + fieldname + "_" + optionname
 +
E.g. <tt>eprint_fieldopt_ispublished_unpub</tt>
 +
 +
If <code>input_style => 'long'</code> then further phrases are required to provide descriptions for each option, in the form:
 +
datasetid + "_optdetails_" + fieldname + "_" + optionname
 +
E.g. <tt>eprint_optdetails_type_book</tt>
  
 
== Database ==
 
== Database ==
 +
Set fields are stored in the database as
 +
fieldname VARCHAR(255)
  
Set fields are stored in the database as
+
== API ==
 +
See [[API:EPrints/MetaField/Set|API page]].
  
  fieldname VARCHAR(255)
+
== Examples ==
 +
Most basic example. (Provides options in a select box).
 +
{
 +
    name => 'pedagogic_type',
 +
    type => 'set',
 +
    options => [qw(
 +
        presentation
 +
        activity
 +
        case
 +
        enquiry
 +
        problem
 +
        collaboration
 +
        communication
 +
    )],
 +
}
 +
Provide options as radio buttons.
 +
{
 +
    name => 'event_type',
 +
    type => 'set',
 +
    options => [qw(
 +
        conference
 +
        workshop
 +
        other
 +
    )],
 +
    input_style => 'medium',
 +
}
 +
Provide options as check boxes.
 +
{
 +
    name => 'availability',
 +
    multiple => 1,
 +
    type => 'set',
 +
    options => [qw(
 +
        print
 +
        electronic
 +
    )],
 +
    input_style => 'medium',
 +
  }
 +
Provide search form options as select box (rather than check boxes).
 +
{
 +
    name => 'pedagogic_type',
 +
    type => 'set',
 +
    options => [qw(
 +
        presentation
 +
        activity
 +
        case
 +
        enquiry
 +
        problem
 +
        collaboration
 +
        communication
 +
    )],
 +
    search_input_style => 'short',
 +
}

Revision as of 23:06, 8 April 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

Allows a set of options to be specified using the options attribute of the field's configuration. The set of options is then displayed in one of several different forms:

  • radio buttons if input_style => 'long' or input_style => 'medium' and multiple => 0.
  • check boxes if input_style => 'long' or input_style => 'medium' and multiple => 1.
  • select box if input_style => 'short'.

When input_style => 'long' is used both names and descriptions for each option will be displayed with radio buttons / check boxes. For input_style => 'medium' only names are displayed.

Inheritance

Properties

name default description
input_ordered 0 ...
input_rows n/a This property is taken from the repository configuration.
input_style short ...
input_tags undef ...
options n/a This property is always required.
render_option undef ...
search_input_style checkbox ...
search_rows n/a This property is taken from the repository configuration.

Required Phrases

If input_style => 'short' or input_style => 'medium' then the only extra phrases required are the name label for each of the options in the form:

datasetid + "_fieldopt_" + fieldname + "_" + optionname

E.g. eprint_fieldopt_ispublished_unpub

If input_style => 'long' then further phrases are required to provide descriptions for each option, in the form:

datasetid + "_optdetails_" + fieldname + "_" + optionname

E.g. eprint_optdetails_type_book

Database

Set fields are stored in the database as

fieldname VARCHAR(255)

API

See API page.

Examples

Most basic example. (Provides options in a select box).

{
    name => 'pedagogic_type',
    type => 'set',
    options => [qw(
        presentation
        activity
        case
        enquiry
        problem
        collaboration
        communication
    )],
}

Provide options as radio buttons.

{
    name => 'event_type',
    type => 'set',
    options => [qw(
        conference
        workshop
        other
    )],
    input_style => 'medium',
}

Provide options as check boxes.

{
    name => 'availability', 
    multiple => 1,
    type => 'set', 
    options => [qw( 
        print 
        electronic 
    )], 
    input_style => 'medium',
}

Provide search form options as select box (rather than check boxes). {

    name => 'pedagogic_type',
    type => 'set',
    options => [qw(
        presentation
        activity
        case
        enquiry
        problem
        collaboration
        communication
    )],
    search_input_style => 'short',
}