Set field

From EPrints Documentation
Jump to: navigation, search

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

Additional Properties

As for Text fields except for

Name Default Value Required Description Notes
form_input_style select NO How to present options in the input form. Only applicable when input_style => 'short'. Any value other than checkbox will display as select box rather than individual checkboxes. checkbox should only be used if multiple => 1
input_ordered 0 NO If multiple values should they be submitted in a specific order Different from Metadata default. Only applicable if multiple => 1. Not normally useful for Set fields as ordering better determined by ordering of options.
input_rows 10 NO Number of rows (i.e. options) to display in select box for input form . The default value for this property is taken from cfg.d/field_property_defaults.pl. Only applicable if input_style => 'short'.
input_style short NO How field is displayed in input form. Can be one of short, medium or long.
input_tags undef NO Use alternative tags for options in input form. If defined must be a function that generates an array of tags. If not defined, tags will be the same as options. Useful if you want to sub-divide sections of options.
match EQ NO How to match values in search results. Different from Text field default (IN). Treat the search value as a single string rather than a whitespace-separated list of words.
merge ANY NO Initial search form setting for whether to match on all or any values (i.e. options). Different from Metadata default (ALL).
order_labels 0 NO Whether to re-order input/search form options based on their labels (e.g. phrase names).
options n/a YES Options to present in input form.
render_max_search_values 5 NO Maximum number of options displayed in search description title of search results.
render_option undef NO How to render individual options. If defined must be a function that generates output to be rendered for a single option. If not datasetid + "_fieldopt_" + fieldname + "_" + optionname phrase will be used.
search_input_style checkbox NO How to present options in search form. Either checkboxes by default or select box if any other value set.
search_rows 12 NO Number of rows (i.e. options_ to display in search form. Only applicable if search_input_style set to something other than checkbox.
sql_index 1 NO Whether field should be index for quicker lookup by the database. Different from Text field default (0).

Required Phrases

In addition to the standard metadata field 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',
}