<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ABlock_formslib</id>
	<title>Development:Block formslib - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ABlock_formslib"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Block_formslib&amp;action=history"/>
	<updated>2026-05-07T14:21:26Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Block_formslib&amp;diff=10852&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Block_formslib&amp;diff=10852&amp;oldid=prev"/>
		<updated>2024-10-21T08:51:01Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 08:51, 21 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Block_formslib&amp;diff=10851&amp;oldid=prev</id>
		<title>1&gt;Poltawski: Changed to reflect the simplified blocks forms</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Block_formslib&amp;diff=10851&amp;oldid=prev"/>
		<updated>2007-05-01T11:06:31Z</updated>

		<summary type="html">&lt;p&gt;Changed to reflect the simplified blocks forms&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;(This is currently a proposal and isn&amp;#039;t available for use see [http://tracker.moodle.org/browse/MDL-9641 MDL-9641]).&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
The block formslib functions are designed to allow developers easily create forms for their blocks.  Please read [[Development:lib/formslib.php]] for full details about using formslib.&lt;br /&gt;
&lt;br /&gt;
= Creating a Global Configuration form =&lt;br /&gt;
&lt;br /&gt;
In order to create a global confuration form using formslib, you must create a file &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/blocks/BLOCKNAME/config_global_form.php&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this file a class needs to be created which follows the naming scheme: block_BLOCKNAME_config_global_form and extends block_config_global_form&lt;br /&gt;
&lt;br /&gt;
In your form configuration class you need to implement the block_configuration() method. Elements added will automatically saved in $CFG.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
require_once $CFG-&amp;gt;dirroot .&amp;#039;/blocks/block_config_global_form.php&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
class block_BLOCKNAME_config_global_form extends block_config_global_form {&lt;br /&gt;
&lt;br /&gt;
    function block_configuration(&amp;amp;$mform){&lt;br /&gt;
&lt;br /&gt;
        // add a html editor text field named block_BLOCKNAME_text&lt;br /&gt;
        $mform-&amp;gt;addElement(&amp;#039;htmleditor&amp;#039;, &amp;#039;block_BLOCKNAME_text&amp;#039;, get_string(&amp;#039;text&amp;#039;,&amp;#039;BLOCKNAME&amp;#039;));&lt;br /&gt;
&lt;br /&gt;
        // This will set the default value of the textfield to &amp;#039;mydefaultstring&amp;#039;. (If $CFG-&amp;gt;textfield &lt;br /&gt;
        // exsts, it will be set to that when the form is loaded)&lt;br /&gt;
        $mform-&amp;gt;setDefault(&amp;#039;mydefaultstring&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
        $mform-&amp;gt;setType(&amp;#039;block_BLOCKNAME_text&amp;#039;, PARAM_RAW);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        $mform-&amp;gt;addElement(&amp;#039;text&amp;#039;, &amp;#039;block_BLOCKNAME_num&amp;#039;, get_string(&amp;#039;block_BLOCKNAME_num&amp;#039;, &amp;#039;BLOCKNAME&amp;#039;));&lt;br /&gt;
&lt;br /&gt;
        $mform-&amp;gt;setDefault(&amp;#039;block_online_users_timetosee&amp;#039;, &amp;#039;5&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
        // Add client side validation which forces the field as numeric&lt;br /&gt;
        $mform-&amp;gt;addRule(&amp;#039;block_BLOCKNAME_num&amp;#039;, null, &amp;#039;numeric&amp;#039;, null, &amp;#039;client&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
        $mform-&amp;gt;setType(&amp;#039;block_BLOCKNAME_num&amp;#039;, PARAM_INT);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Creating a Instance Configuration form =&lt;br /&gt;
&lt;br /&gt;
In order to create a global confuration form using formslib, you must create a file &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/blocks/BLOCKNAME/config_instance_form.php&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this file a class needs to be created which follows the naming scheme: block_BLOCKNAME_config_instance_form and extends block_config_instance_form.&lt;br /&gt;
&lt;br /&gt;
In your form configuration class you need to implement the instance_configuration() method. Elements added will automatically saved in $block-&amp;gt;config&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require_once $CFG-&amp;gt;dirroot .&amp;#039;/blocks/block_config_instance_form.php&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
class block_BLOCKNAME_config_instance_form extends block_config_instance_form {&lt;br /&gt;
&lt;br /&gt;
    function instance_configuration(&amp;amp;$mform){&lt;br /&gt;
&lt;br /&gt;
        // add a text field named title&lt;br /&gt;
        $mform-&amp;gt;addElement(&amp;#039;text&amp;#039;,&amp;#039;title&amp;#039;,get_string(&amp;#039;configtitle&amp;#039;, &amp;#039;BLOCKNAME&amp;#039;));&lt;br /&gt;
&lt;br /&gt;
        // this will set the form field to &amp;#039;my title&amp;#039;&lt;br /&gt;
        // (if a title string is already stored in the block instance&lt;br /&gt;
        // configuration, it will automatically be set it to that)&lt;br /&gt;
        $mform-&amp;gt;setDefault(&amp;#039;title&amp;#039;, &amp;#039;my title string&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
        $mform-&amp;gt;setType(&amp;#039;title&amp;#039;, PARAM_NOTAGS);&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>1&gt;Poltawski</name></author>
	</entry>
</feed>