<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ASFfield%2Fclass%2Fdoc</id>
	<title>Modul:SFfield/class/doc - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ASFfield%2Fclass%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SFfield/class/doc&amp;action=history"/>
	<updated>2026-04-05T22:33:11Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Verzauberte Welten e.V.</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.verzauberte-welten.de/index.php?title=Modul:SFfield/class/doc&amp;diff=4426&amp;oldid=prev</id>
		<title>imported&gt;Oetterer am 11. Februar 2016 um 21:05 Uhr</title>
		<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SFfield/class/doc&amp;diff=4426&amp;oldid=prev"/>
		<updated>2016-02-11T21:05:25Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{documentation subpage}}&lt;br /&gt;
{{module rating|protected}}&lt;br /&gt;
&amp;lt;!-- Categories go at the bottom of this page and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a Class Module. It implements a class in Lua using [[Module:Middleclass]]. This class provides methods for defining and creating Semantic Forms field-tags.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
local classSFfield = require('Module:SFfield/class')&lt;br /&gt;
local field = classSFfield:new('name')&lt;br /&gt;
classSFfield:setDefaultSize(80)&lt;br /&gt;
field:set('input type', 'tokens')&lt;br /&gt;
field:set('list')&lt;br /&gt;
field:set('mandatory', true)&lt;br /&gt;
field:set('property', 'goes by name')&lt;br /&gt;
local output = field:render()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This class provides meththods for creating field tags to use in Semantic Forms. It is fast, easy to use and does some minor plausibility checks:&lt;br /&gt;
* it only allows existing attributes to be set&lt;br /&gt;
* it only allows existing &amp;quot;input type&amp;quot;s to be set&lt;br /&gt;
Concerniny &amp;quot;existing&amp;quot;: The module knows all input types from Semantic Forms and Semantic Forms Inputs. All valid entries are defined in [[#Configuration Data|Configuration Data]]&lt;br /&gt;
&lt;br /&gt;
Besides some debugging, the class does not print any error reports or development output. See [[Module:Debug/class]] for more information on how to access debug output.&lt;br /&gt;
&lt;br /&gt;
There is are some static properties to default certain values when not set individually:&lt;br /&gt;
* &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; for &amp;quot;tokens&amp;quot;, &amp;quot;combobox&amp;quot;, &amp;quot;text&amp;quot;, ... fields&lt;br /&gt;
* &amp;lt;code&amp;gt;autogrow&amp;lt;/code&amp;gt; for &amp;quot;textarea&amp;quot; and &amp;quot;textarea with autocomplete&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;cols&amp;lt;/code&amp;gt; for &amp;quot;textarea&amp;quot; and &amp;quot;textarea with autocomplete&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;editor&amp;lt;/code&amp;gt; for &amp;quot;textarea&amp;quot; and &amp;quot;textarea with autocomplete&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;rows&amp;lt;/code&amp;gt; for &amp;quot;textarea&amp;quot; and &amp;quot;textarea with autocomplete&amp;quot;&lt;br /&gt;
&lt;br /&gt;
They are initialized in the class but can be overwritten by [[#static methods|static methods]].&lt;br /&gt;
&lt;br /&gt;
Besides simple field-tags there is also a method with which you can have your tags enclosed in the typical tr-th-td structure to easily create a form table. You can also add a tooltip. If &amp;lt;code&amp;gt;mandatory&amp;lt;/code&amp;gt; was set, it also prints a small asterix next to the label.&lt;br /&gt;
&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
local node = field:createTr('Name', 'This field holds the full name, the person is known for.')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Constructor ==&lt;br /&gt;
=== new(fieldname) ===&lt;br /&gt;
Creates a new Object for class Name.&lt;br /&gt;
;fieldname&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:holds the name of the field; in SF-terms: this transforms to the parameter name of the referenced template&lt;br /&gt;
;return&lt;br /&gt;
:object, of class SFfield&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
=== Public methods ===&lt;br /&gt;
==== __tostring() ====&lt;br /&gt;
Returns a string representation of the field by calling [[#render()|render()]].&lt;br /&gt;
{{small|&lt;br /&gt;
;return&lt;br /&gt;
:string, representation of itself&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== createTr(label, tooltip) ====&lt;br /&gt;
Uncloses the rendered field in a tr-th-td structure that can directly be used in an html formtable. When &amp;lt;code&amp;gt;mandatory&amp;lt;/code&amp;gt; is set in the field, it adds an asterix after the label. A tooltip can also be provided.&lt;br /&gt;
{{small|&lt;br /&gt;
;label&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:what var is for&lt;br /&gt;
;tooltip&lt;br /&gt;
:string, optional&lt;br /&gt;
:explanatory text that helps the user fill this field&lt;br /&gt;
;return&lt;br /&gt;
:object of class mw.html, one table row (tr) containing an th with the labal (and tooltip) and a tr with the rendered field.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== get(attribute) ====&lt;br /&gt;
Returns the value for the attribute.&lt;br /&gt;
{{small|&lt;br /&gt;
;attribute&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:the name of the attribute, you wish to get&lt;br /&gt;
;return&lt;br /&gt;
:vaiable, the value for the attribute&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== render() ====&lt;br /&gt;
Renders the object and creates a semantic forms field already htmlentities-encoded (so it can be used directly in the form)&lt;br /&gt;
{{small|&lt;br /&gt;
;return&lt;br /&gt;
:string, rendered and encoded field-tag&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== set(attribute, value) ====&lt;br /&gt;
Sets an attribute for the field. Checks attribute for validity before setting it. In case of attribute &amp;lt;code&amp;gt;input type&amp;lt;/code&amp;gt; checks value for validity, too. When setting simple attributes like &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mandatory&amp;lt;/code&amp;gt;, omitting value is interpreted as adding the attribute. If you at anytime wish to remove such an attribute, you have to set value to false.&lt;br /&gt;
{{small|&lt;br /&gt;
;attribute&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:the name of the attribute, you wish to set&lt;br /&gt;
;value&lt;br /&gt;
:(string|integer|boolean|table), mandatory&lt;br /&gt;
:the value, you wish to set the attribute to.&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== static methods ===&lt;br /&gt;
==== SFfield:getShowOnSelectIdPrefix() ====&lt;br /&gt;
Returns the static property used as prefix in the html-id attribute that serves as identifier for the &amp;lt;code&amp;gt;show on select&amp;lt;/code&amp;gt; mechanism. When using the method [[#createTr(label, tooltip)|createTr]], you probably have no need for this.&lt;br /&gt;
{{small|&lt;br /&gt;
;return&lt;br /&gt;
:string, prefix for the value of the id attribute&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setDefaultSize(val) ====&lt;br /&gt;
Sets the default size for text-like fields (tokens, combobox, text, ...). The default only applies, if this attribute is not set individually in a textarea field.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:integer, mandatory&lt;br /&gt;
:default size in characters for input fields&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setDefaultTextAreaAutogrow(val) ====&lt;br /&gt;
Sets the default autogrow-behaviour of textarea-type fields. The default only applies, if this attribute is not set individually in a textarea field.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:boolean, mandatory&lt;br /&gt;
:disables or enables default value for autogrow in textarea fields.&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setDefaultTextAreaCols(val) ====&lt;br /&gt;
Sets the default for number of columns for textarea-type fields. The default only applies, if this attribute is not set individually in a textarea field.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:integer, mandatory&lt;br /&gt;
:default for number of columns for the textarea fields.&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setDefaultTextAreaEditor(val) ====&lt;br /&gt;
Sets the default editor of textarea-type fields. The default only applies, if this attribute is not set individually in a textarea field.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:string|boolean, mandatory&lt;br /&gt;
:disables or enables default wikieditor for textarea fields (boolean) or set editor to this value (string).&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setDefaultTextAreaRows(val) ====&lt;br /&gt;
Sets the default for number of rows for textarea-type fields. The default only applies, if this attribute is not set individually in a textarea field.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:integer, mandatory&lt;br /&gt;
:default for number of rows for the textarea fields.&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== SFfield:setShowOnSelectIdPrefix(val) ====&lt;br /&gt;
Sets the default prefix for the html id-attribute used in the &amp;lt;code&amp;gt;show on select&amp;lt;/code&amp;gt; complex.&lt;br /&gt;
{{small|&lt;br /&gt;
;val&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:the static property will be set to this value&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether setting was successful or not&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== private methods ===&lt;br /&gt;
==== _processAttributes(self) ====&lt;br /&gt;
Converts the private property attributes (which holds all attributes for this field) from an array {attribute = value, ...} table to a sequence {'attriubte=value', ..} table. Also:&lt;br /&gt;
* adds the attribute 'input type' if missing to a default, depending on setting of attribute 'list'&lt;br /&gt;
* sets defaults (if applicable) for&lt;br /&gt;
** size&lt;br /&gt;
** autogrow&lt;br /&gt;
** cols&lt;br /&gt;
** editor&lt;br /&gt;
** rows&lt;br /&gt;
* does the 'show on select' table-conversion if necessary&lt;br /&gt;
{{small|&lt;br /&gt;
;self&lt;br /&gt;
:object, me&lt;br /&gt;
;var&lt;br /&gt;
:type(string|integer|boolean|table), (mandatory|optional)&lt;br /&gt;
:what var is for&lt;br /&gt;
;return&lt;br /&gt;
:table, of attributes as sequence&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
=== static ===&lt;br /&gt;
;_CFG&lt;br /&gt;
:table, holds configuration data found in Module:Name/config&lt;br /&gt;
:'''WARNING:''' This is a read only table and besides functions ''pairs()'' and ''ipairs()'' nothing else will work on it, especially not the functions of the table library!&lt;br /&gt;
* global, table, global behaviour settings&lt;br /&gt;
* validAttributes, table, a sequence of all valid attributes&lt;br /&gt;
* validInputTypes, table, a sequence of all valid values for attribute &amp;quot;input type&amp;quot;&lt;br /&gt;
;_TT&lt;br /&gt;
:table, instance of [[Module:TableTools]]&lt;br /&gt;
;_defaultListInputType&lt;br /&gt;
:string, default value for attribute &amp;quot;input type&amp;quot; if unset. applies if &amp;quot;list&amp;quot; is set&lt;br /&gt;
;_defaultSingleInputType&lt;br /&gt;
:string, default value for attribute &amp;quot;input type&amp;quot; if unset. applies if &amp;quot;list&amp;quot; is not set&lt;br /&gt;
;_defaultSize&lt;br /&gt;
:integer, default size for most input types if not set&lt;br /&gt;
;_defaultTextAreaAttributes&lt;br /&gt;
:table, holds some default attribte values for textarea fields if unset&lt;br /&gt;
;_mandatoryMarker&lt;br /&gt;
:string, [[#createTr(label, tooltip)|createTr]] uses this marker to depict mandatory fields&lt;br /&gt;
;_showOnSelectIdPrefix&lt;br /&gt;
:string, prefix string for html id-attributes for the show on select complex (e.g.: '&amp;lt;tr id=&amp;quot;' .. _showOnSelectIdPrefix .. fieldname .. '&amp;quot;&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== private ===&lt;br /&gt;
Note: all private properties are stored in table ''_private[self]''. _private is a static array that is indexed by ''self'', so the table ''_private[self]'' holds all properties for instance ''self''.&lt;br /&gt;
;attributes&lt;br /&gt;
:table, holds &amp;quot;my&amp;quot; attributes&lt;br /&gt;
;dbg&lt;br /&gt;
:object, my instance of [[Module:Debug/class]] for debugging purposes&lt;br /&gt;
;name&lt;br /&gt;
:string, name of this field&lt;br /&gt;
&lt;br /&gt;
== Configuration Data ==&lt;br /&gt;
This class holds it control data in [[Module:{{BASEPAGENAME}}/config]]. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Class engine]]&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
&amp;lt;!-- Categories go here if you wish an additional category to that set in {{module rating}} above automatically. --&amp;gt;&lt;br /&gt;
[[Category:Lua metamodules]][[Category:Lua class modules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Oetterer</name></author>
	</entry>
</feed>