XOOPS  2.6.0
sampleform.inc.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
28 $sample_form = new Xoops\Form\ThemeForm('', 'sample_form', 'action.php');
29 $sample_form->setExtra('enctype="multipart/form-data"');
30 // Not required but for user-friendly concern
31 $editor = !empty($_REQUEST['editor']) ? $_REQUEST['editor'] : '';
32 if (!empty($editor)) {
33  setcookie('editor', $editor); // save to cookie
34 } else {
35  // Or use user pre-selected editor through profile
36  if ($xoops->isUser()) {
37  $editor = @ $xoops->user->getVar('editor'); // Need set through user profile
38  }
39  // Add the editor selection box
40  // If dohtml is disabled, set $noHtml = true
41  $sample_form->addElement(new Xoops\Form\SelectEditor($sample_form, 'editor', $editor, $noHtml = false));
42  // options for the editor
43  // required configs
44  $options['editor'] = $editor;
45  $options['name'] = 'required_element';
46  $options['value'] = empty($_REQUEST['message']) ? "" : $_REQUEST['message'];
47  // optional configs
48  $options['rows'] = 25; // default value = 5
49  $options['cols'] = 60; // default value = 50
50  $options['width'] = '100%'; // default value = 100%
51  $options['height'] = '400px'; // default value = 400px
52 
53 
54  // "textarea": if the selected editor with name of $editor can not be created, the editor "textarea" will be used
55  // if no $onFailure is set, then the first available editor will be used
56  // If dohtml is disabled, set $noHtml to true
57  $sample_form->addElement(new Xoops\Form\Editor('Your message', $options['name'], $options, $nohtml = false, $onfailure = 'textarea'), true);
58  $sample_form->addElement(new Xoops\Form\Text('SOME REQUIRED ELEMENTS', 'required_element2', 50, 255, $required_element2), true);
59  $sample_form->addElement(new Xoops\Form\Button('', 'save', XoopsLocale::A_SUBMIT, 'submit'));
60  $sample_form->display();
61 }
const A_SUBMIT
Definition: en_US.php:128
static getInstance()
Definition: Xoops.php:160
$options['editor']
$xoops
$sample_form
$editor