Difference between revisions of "Set field"

From EPrints Documentation
Jump to: navigation, search
 
m (Additional Properties)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
* [[Metadata]]
+
{{fieldtypes}}
** [[Set field]]
+
 
  
 
== Description ==
 
== 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 ==
 +
* [[Metadata]]
 +
** [[Id field]]
 +
*** [[Text field]]
 +
**** [[Set field]]
  
== Properties ==
+
== Additional Properties ==
 +
As for [[Text field#Additional_Properties|Text fields]] except for
  
 
{| border="1" cellpadding="3" cellspacing="0"
 
{| border="1" cellpadding="3" cellspacing="0"
| name || default || description
+
! Name !! Default Value !! Required !! Description !! Notes
 +
|-
 +
| '''form_input_style''' || <tt>select</tt> || NO || How to present options  in the input form. || Only applicable when <tt>input_style => 'short'</tt>.  Any value other than <tt>checkbox</tt> will display as <tt>select</tt> box rather than individual checkboxes.  <tt>checkbox</tt> should only be used if <tt>multiple => 1</tt>
 +
|-
 +
| '''input_ordered''' || <tt>0</tt> || NO || If multiple values should they be submitted in a specific order || Different from [[Metadata]] default. Only applicable if <tt>multiple => 1</tt>.  Not normally useful for Set fields as ordering better determined by ordering of <tt>options</tt>.
 +
|-
 +
| '''input_rows''' || <tt>10</tt> || NO || Number of rows (i.e. options) to display in select box for input form . || The default value for this property is taken from <tt>cfg.d/field_property_defaults.pl</tt>. Only applicable if <tt>input_style => 'short'</tt>.
 +
|-
 +
| '''input_style''' || <tt>short</tt> || NO || How field is displayed in input form. || Can be one of <tt>short</tt>, <tt>medium</tt> or <tt>long</tt>.
 +
|-
 +
| '''input_tags''' || <tt>undef</tt> || 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''' || <tt>EQ</tt> || NO || How to match values in search results. || Different from [[Text field]] default (<tt>IN</tt>). Treat the search value as a single string rather than a whitespace-separated list of words.
 
|-
 
|-
| '''input_ordered''' || 0 || ...
+
| '''merge''' || <tt>ANY</tt> || NO || Initial search form setting for whether to match on all or any values (i.e. options). || Different from [[Metadata]] default (<tt>ALL</tt>).
 
|-
 
|-
| '''input_rows''' || n/a || '''This property is taken from the repository configuration.'''
+
| '''order_labels''' || <tt>0</tt> || NO || Whether to re-order input/search form options based on their labels (e.g. phrase names). ||
 
|-
 
|-
| '''input_style''' || short || ...
+
| '''options''' || n/a || YES || Options to present in input form. ||
 
|-
 
|-
| '''input_tags''' || undef || ...
+
| '''render_max_search_values''' || <tt>5</tt> || NO || Maximum number of options displayed in search description title of search results. ||
 
|-
 
|-
| '''options''' || n/a || '''This property is always required.'''
+
| '''render_option''' || <tt>undef</tt> || NO || How to render individual options. || If defined must be a function that generates output to be rendered for a single option.  If not <tt>datasetid + "_fieldopt_" + fieldname + "_" + optionname</tt> phrase will be used.
 
|-
 
|-
| '''render_option''' || undef || ...
+
| '''search_input_style''' || <tt>checkbox</tt> || NO || How to present options in search form. || Either checkboxes by default or select box if any other value set.
 
|-
 
|-
| '''search_input_style''' || checkbox || ...
+
| '''search_rows''' || <tt>12</tt> || NO || Number of rows (i.e. options_ to display in search form. || Only applicable if <tt>search_input_style</tt> set to something other than <tt>checkbox</tt>.
 +
|-
 +
| '''sql_index''' || <tt>1</tt> || NO || Whether field should be index for quicker lookup by the database. || Different from [[Text field]] default (<tt>0</tt>).
 
|-
 
|-
| '''search_rows''' || n/a || '''This property is taken from the repository configuration.'''
 
 
|}
 
|}
  
 
== Required Phrases ==
 
== Required Phrases ==
 +
In addition to the [[Metadata#Required_Phrases|standard metadata field 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 ==
 +
Set fields are stored in the database as
 +
fieldname VARCHAR(255)
 +
 +
== API ==
 +
See [[API:EPrints/MetaField/Set|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',
 +
}

Latest revision as of 15:48, 10 May 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

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