Extension:Page Forms/Input types/cs

Tato stránka se zabývá různými typy vstupů, které jsou k dispozici v rámci formulářů stránek, a parametry a další přizpůsobení, které lze pro ně nastavit.



text
Výchozí typ vstupu; odpovídá "textovému" vstupu HTML.

Speciální parametry:

textarea
Odpovídá HTML značce.

Speciální parametry:



text s automatickým doplňováním, textová oblast s automatickým doplňováním
These were formerly real input types, but have been aliases for "combobox" or "tokens" (depending on whether the input holds a list of values, or just one) since version 5.0.

combobox
Typ vstupu "combobox" poskytuje rozhraní combo box: vstup, který funguje jako běžné pole automatického doplňování, ale má další ikonu šipky dolů, jako je rozbalovací nabídka, která uživateli umožňuje zobrazit všechny dostupné hodnoty najednou. Je implementován pomocí knihovny.

Speciální parametry:

tokens
Tento typ vstupu "tokenizuje" hodnoty v poli, tj. umístí kolem každé hodnoty blok, aby se z ní stala jedna jednotka namísto pouhého řetězce znaků. Tyto "tokeny"“ pak lze také přeskládat. Tento vstup je implementován pomocí JavaScriptové knihovny Select2.

Speciální parametry:

Ve výchozím nastavení se "tokeny" zobrazují jako jednořádkový vstup a poté se v případě potřeby vertikálně rozšíří, pokud jsou přidány další hodnoty. V některých případech můžete chtít, aby se tento vstup na začátku jevil vyšší než jeden řádek, aby bylo uživatelům jasnější, že se rozšíří. Chcete-li to provést pro jeden vstup, přidejte do značky pole parametr, například " ", a poté do MediaWiki:Common.css přidejte něco jako následující:

Pokud chcete, aby to platilo pro všechny vstupy "tokenů" na wiki, přidejte místo toho do MediaWiki:Common.css něco takového:

radiobutton
Vstup "radiobutton" odpovídá HTML vstupu "radio". Zobrazuje sadu hodnot, ze kterých si uživatel může vybrat pouze jednu.

Ve výchozím nastavení je první hodnota přepínacího tlačítka "None" (žádné), což uživateli umožňuje vybrat prázdnou hodnotu. Chcete-li zabránit zobrazení "None", musíte pole nastavit jako "povinné" (mandatory) a také nastavit jednu z povolených hodnot jako hodnotu "default=" (výchozí).

dropdown
Vstup "dropdown" (rozbalovací) odpovídá HTML značce. Zobrazuje rozbalovací seznam hodnot, z nichž si uživatel může vybrat pouze jednu.

checkboxes
Vstup "checkboxes" (zaškrtávací políčka) zobrazuje zaškrtávací políčka, která umožňují uživateli vybrat libovolný počet hodnot. Pokud je zaškrtávacích políček více než určitý počet, nad sadou zaškrtávacích políček se automaticky zobrazí odkazy"Select all" (vybrat vše) a "Select none" (nevybrat žádné), což uživatelům umožní automaticky zaškrtnout všechna nebo žádná z nich. Toto číslo je diktováno proměnnou, která je ve výchozím nastavení 10, i když ji lze změnit v LocalSettings.php.

Speciální parametry:

listbox
Vstup "listbox" odpovídá HTML značce &lt;select&gt; s přidaným atributem "multiple". Zobrazuje vertikální seznam možností, kde si uživatel může vybrat libovolný počet hodnot.

Speciální parametry:

tree
Typ vstupu "tree" (strom) umožňuje hierarchické zadávání ve stromovém stylu, kde všechny hodnoty mají vedle sebe buď přepínací tlačítka, nebo zaškrtávací políčka, v závislosti na tom, zda pole může obsahovat jednu nebo více položek. Values can either come from a category tree within the wiki, or be set manually within the form definition.

How does this input know whether it can hold one or multiple values, and should thus display radiobuttons vs. checkboxes? It checks whether the field in the template is defined as holding a list of values (using #arraymap) or not. This check is not perfect, though. If the tree input is showing radiobuttons instead of checkboxes, you just need to add the parameter "|list" to the field tag in the form definition, to establish that this is a list.

Depending on the source of the values, you need to specify one of these two additional parameters:


 * - sets the name of the category at the top of the "tree".
 * - sets the entire tree structure; should use wikitext-style bullets to set the depth level.

If you use the "structure" parameter, it should look something like this:

You can also optionally set these parameters:


 * - sets the height, in pixels, of the box in which the tree appears.
 * - sets the width, in pixels, of the box in which the tree appears.
 * - sets the delimiter when the field can hold a list of values. Default is ','.
 * - hides the name of the top category.
 * - sets the number of levels of the tree that are shown at the beginning. Default is 10.

You can see a sample form that uses this input type here.

For category names
If you're using the "tree" input type to display a category tree, note that this input will print out only the names of the categories selected, without the "Category:" namespace before it; so if you want that to show up in the page as well, the template will have to add it.

If the field specifies multiple categories, and the template uses #arraymap to do it, the call to #arraymap should look something like:

...in other words, you need to specify the final "delimiter" parameter for #arraymap, and make it a space, blank or something similar, to avoid printing commas between the category tags.

checkbox
A single checkbox, used for boolean values.

Special parameters:

date
This input contains three separate entries, for the year, month and day.

datetime
The "datetime" input is similar to the "date" input, but includes additional entries for hours, minutes, seconds and AM/PM.

Special parameters:

year
"year" is a simple text input that is used to get a year-only value for a date field.

datepicker
"datepicker" lets the user pick a date with the help of a JavaScript-based popup calendar.

Special parameters:

The starting day of the week (e.g., Saturday, Sunday or Monday) is set based on the language of the wiki; it unfortunately cannot be set independently of the language. If your wiki is in English and you would like weeks in the calendar input to start on Monday instead of Sunday (which is the default), you can do that by setting your wiki's language to be "en-gb" instead of "en".

datetimepicker
"datetimepicker" is a JavaScript-based input type very similar to "datepicker", but it includes popups for selecting both the date and time. It defaults to. Its set of parameters includes all of those "datepicker" as well as the following:

rating
The "rating" input type displays a set of stars to let the user enter a rating.

Special parameters:

googlemaps, leaflet, openlayers
The "googlemaps", "leaflet" and "openlayers" input types let you display a map to get a coordinate value, using the Google Maps, Leaflet or OpenLayers services, respectively.

If you are using the "googlemaps" input, you may need to get a Google Maps API key, then set it in LocalSettings.php via the  setting, for the input to display.

You can also optionally set these parameters for these input types:

The "leaflet" input type also allows one additional parameter:

All of the map inputs lets you enter an address to locate the coordinates more easily. But if the form already contains one or more fields to enter the address, then the user may have to enter it twice - once to actually store the data, and the second to locate the coordinates. To avoid users having to do this double work, you can have the address field(s) feed their values directly to the map when locating the point. You can do that using the "feeds to map=" parameter - look for "feeds to map" here.

All of these formats, by default, rely on external JavaScript code. However, you can have the "openlayers" format use local JavaScript code instead, by just installing the OpenLayers extension.

Disabling
Note that these input types all send your wiki's data (that is, the data contained in the query results) to external services. They are the only part of the Page Forms code that sends data externally, other than autocompleting on outside values, though that one requires additional configuration to run. If you have a private wiki and are very concerned about no data getting out, you may want to add the following to LocalSettings.php:

This will disallow the use of any outside services by Page Forms - which at the moment means disabling these three input types.

regexp
The "regexp" input type is not a true input type, but rather the ability to display another input (most often "text") with additional, regular-expression-based validation. See here for a more detailed explanation of this input type and its parameters.

Allowed input types for data types
Each defined data type, when using either Cargo or Semantic MediaWiki, has a default input type, and, when applicable, a default input size as well. Additionally, some data types have special handling if the field holds a delimited list of values, instead of just a single value.

Here are the defaults and the other allowed input types for each data type, for single values:

And here are the default and other allowed input types for delimited lists of a certain data type:

Uploading files
If a field in the form is meant to hold the name of an uploaded file (say, an image), you can allow users to upload this file directly through the form. This is done simply by adding the parameter "uploadable" to that field's declaration in the form definition. This will add a link reading "Upload file" next to this field in the form; if the user clicks on this link, it will pop up a "lightbox"-style window (using the FancyBox JavaScript library) that lets the user upload a file. Once the user has done so, the window will close, and the field will contain the name of the uploaded file. If the field is configured to contain a list of values, the new filename will be appended to whatever was there before; otherwise, the filename will overwrite whatever the field contained before.

Note that the "uploadable" parameter can only be used in fields of type "text", "text with autocomplete", "combobox" or "tokens".

For uploadable fields, you can also set the default filename of the uploaded files, by setting the "default filename=" parameter in the field definition. The value of this parameter can include parser functions, magic words and the like. It can also include the variable "&lt;page name>", which gets substituted with the name of the page being added or edited. So adding to the field definition the parameter "default filename=Image for &lt;page name>", for instance, for a page called "Abc", would set the default name of any uploaded file to "Image for Abc". Note that if you simply want to specify a default file to use such as "Imageneeded.png" the regular "default=Imageneeded.png" parameter will do.

You can see a demonstration of file uploading here.

Note that the upload window will not work if  is set to   in your LocalSettings.php file.

You can also set uploadable fields to use the operating system's own uploading directly, instead of using MediaWiki's uploading system - this gives the user fewer options, but it is a simpler process, and on mobile devices it can present some interesting options, like uploading photos right after they are taken. To do this, add the following line to LocalSettings.php file:

The special parameters for uploadable fields are:
 * - Specifies that this is an uploadable field.
 * - Specifies that a thumbnail of the uploaded image should be placed under the field in the form.
 * filename - Specifies the default filename for files uploaded with this field.