1<?php
2/**
3 * Class helper_plugin_bureaucracy_fieldhidden
4 *
5 * Creates an invisible field with static data
6 */
7class helper_plugin_bureaucracy_fieldhidden extends helper_plugin_bureaucracy_field {
8
9    /**
10     * Arguments:
11     *  - cmd
12     *  - label
13     *  - =default value
14     */
15
16    /**
17     * Render the field as XHTML
18     *
19     * Outputs the represented field using the passed Doku_Form object.
20     *
21     * @param array     $params Additional HTML specific parameters
22     * @param Doku_Form $form   The target Doku_Form object
23     * @param int       $formid unique identifier of the form which contains this field
24     */
25    function renderfield($params, Doku_Form $form, $formid) {
26        $this->_handlePreload();
27        $form->addHidden($params['name'], $this->getParam('value') . '');
28    }
29
30    /**
31     * Get an arbitrary parameter
32     *
33     * @param string $name
34     * @return mixed|null
35     */
36    function getParam($name) {
37        if (!isset($this->opt[$name]) || in_array($name, array('pagename', 'value')) && $this->hidden) {
38            return null;
39        }
40        if ($name === 'pagename') {
41            // If $this->opt['pagename'] is set, return the value of the field,
42            // UNESCAPED.
43            $name = 'value';
44        }
45        return $this->opt[$name];
46    }
47}
48