Difference between revisions of "Longtext counter field"
(Added Longtext_counter field) |
(→Additional Properties) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{fieldtypes}} | {{fieldtypes}} | ||
− | + | ||
+ | |||
+ | == Description == | ||
+ | A [[Longtext field]] but with a counter for number of words used displayed next to the input field. Maximum number of words can be specified as a guide but not enforced. <tt>maxlength</tt> attribute can be used to enforce maximum number of characters as a suitable multiple (e.g. 7.5) of the <tt>maxwords</tt>. | ||
+ | |||
+ | Requires [https://jquery.com/download/ jQuery] JavaScript library to be added to the archive as <tt>cfg/static/javascript/auto/directory/00_jquery.js</tt>. Tested to work with latest (v3.5.1) version of jQuery. May cause issues with existing JavaScript within EPrints. | ||
+ | |||
== Inheritance == | == Inheritance == | ||
− | |||
* [[Metadata]] | * [[Metadata]] | ||
** [[Text field]] | ** [[Text field]] | ||
Line 8: | Line 13: | ||
**** [[Longtext_counter field]] | **** [[Longtext_counter field]] | ||
− | == | + | == Additional Properties == |
− | + | As for [[Longtext field#Additional_Properties|Longtext fields]] except for: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | As for [[Longtext field]] | ||
{| border="1" cellpadding="3" cellspacing="0" | {| border="1" cellpadding="3" cellspacing="0" | ||
− | + | ! Name !! Default Value !! Required !! Description !! Notes | |
|- | |- | ||
− | | '''maxwords''' || | + | | '''maxwords''' || <tt>500</tt> || NO || Maximum number of words that should be entered into the <tt>textarea</tt> in the input form. || Counter warns if word limit is exceeded but does not prevent. |
|} | |} | ||
== Required Phrases == | == Required Phrases == | ||
+ | No additional phrases beyond those required for [[Longtext field#Required_Phrases|Longtext fields]]. | ||
+ | |||
+ | == Database == | ||
+ | Longtext fields are stored in the database as | ||
+ | |||
+ | fieldname LONGTEXT | ||
+ | |||
+ | == API == | ||
+ | See [[API:EPrints/MetaField/Longtext_counter|API page]]. | ||
+ | |||
+ | == Examples == | ||
+ | Most basic example. | ||
+ | { | ||
+ | name => 'task_purpose', | ||
+ | type => 'longtext_counter', | ||
+ | } | ||
+ | Restricting maximum number of words. This will not stop user going over this amount but they will see they have exceeded the word limit. | ||
+ | { | ||
+ | name => 'task_purpose', | ||
+ | type => 'longtext_counter', | ||
+ | max_words => 200, | ||
+ | } | ||
+ | Restricting on maximum number of words and maximum length (in characters). To prevent the user going wildly over the word limit setting a <tt>maxlength</tt> will prevent them typing over a certain number of characters. Even including spaces and punctuation, English will rarely if ever exceed 7.5 characters per word ratio used in the following example. | ||
+ | { | ||
+ | name => 'task_purpose', | ||
+ | type => 'longtext_counter', | ||
+ | max_words => 200, | ||
+ | maxlength => 1500, | ||
+ | } |
Latest revision as of 15:15, 15 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
Contents
Description
A Longtext field but with a counter for number of words used displayed next to the input field. Maximum number of words can be specified as a guide but not enforced. maxlength attribute can be used to enforce maximum number of characters as a suitable multiple (e.g. 7.5) of the maxwords.
Requires jQuery JavaScript library to be added to the archive as cfg/static/javascript/auto/directory/00_jquery.js. Tested to work with latest (v3.5.1) version of jQuery. May cause issues with existing JavaScript within EPrints.
Inheritance
Additional Properties
As for Longtext fields except for:
Name | Default Value | Required | Description | Notes |
---|---|---|---|---|
maxwords | 500 | NO | Maximum number of words that should be entered into the textarea in the input form. | Counter warns if word limit is exceeded but does not prevent. |
Required Phrases
No additional phrases beyond those required for Longtext fields.
Database
Longtext fields are stored in the database as
fieldname LONGTEXT
API
See API page.
Examples
Most basic example.
{ name => 'task_purpose', type => 'longtext_counter', }
Restricting maximum number of words. This will not stop user going over this amount but they will see they have exceeded the word limit.
{ name => 'task_purpose', type => 'longtext_counter', max_words => 200, }
Restricting on maximum number of words and maximum length (in characters). To prevent the user going wildly over the word limit setting a maxlength will prevent them typing over a certain number of characters. Even including spaces and punctuation, English will rarely if ever exceed 7.5 characters per word ratio used in the following example.
{ name => 'task_purpose', type => 'longtext_counter', max_words => 200, maxlength => 1500, }