当前位置: 首页>>代码示例>>PHP>>正文


PHP HTML_QuickForm::__construct方法代码示例

本文整理汇总了PHP中HTML_QuickForm::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::__construct方法的具体用法?PHP HTML_QuickForm::__construct怎么用?PHP HTML_QuickForm::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTML_QuickForm的用法示例。


在下文中一共展示了HTML_QuickForm::__construct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function __construct($formName = '', $method = 'POST', $action = '', $target = '', $attributes = null, $trackSubmit = true)
 {
     parent::__construct($formName, $method, $action, $target, $attributes, $trackSubmit);
     $this->id = $formName;
     $this->forceClientValidation = false;
     $this->hasRequiredFields = false;
     //register custom fields
     parent::registerElementType('html', MAX_PATH . '/lib/OA/Admin/UI/component/Html.php', 'OA_Admin_UI_Component_Html');
     parent::registerElementType('controls', MAX_PATH . '/lib/OA/Admin/UI/component/FormControls.php', 'OA_Admin_UI_Component_FormControls');
     parent::registerElementType('break', MAX_PATH . '/lib/OA/Admin/UI/component/FormBreak.php', 'OA_Admin_UI_Component_FormBreak');
     parent::registerElementType('custom', MAX_PATH . '/lib/OA/Admin/UI/component/CustomFormElement.php', 'OA_Admin_UI_Component_CustomFormElement');
     parent::registerElementType('plugin-custom', MAX_PATH . '/lib/OA/Admin/UI/component/CustomPluginFormElement.php', 'OA_Admin_UI_Component_CustomPluginFormElement');
     parent::registerElementType('script', MAX_PATH . '/lib/OA/Admin/UI/component/ScriptFormElement.php', 'OA_Admin_UI_Component_ScriptFormElement');
     parent::registerElementType('plugin-script', MAX_PATH . '/lib/OA/Admin/UI/component/PluginScriptFormElement.php', 'OA_Admin_UI_Component_PluginScriptFormElement');
     //register additional rules
     $this->registerRule('wholenumber', 'regex', '/^\\d+$/');
     $this->registerRule('wholenumber-', 'regex', '/^\\d+$|^\\-$/');
     $this->registerRule('formattednumber', 'regex', '/^\\d+$|^\\d(,\\d{3})+$/');
     $this->registerRule('decimal', 'regex', '/^([+-])?\\d+(\\.\\d+)?$/');
     $this->registerRule('decimalplaces', 'rule', 'OA_Admin_UI_Rule_DecimalPlaces', MAX_PATH . '/lib/OA/Admin/UI/component/rule/DecimalPlaces.php');
     $this->registerRule('min', 'rule', 'OA_Admin_UI_Rule_Min', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Min.php');
     $this->registerRule('max', 'rule', 'OA_Admin_UI_Rule_Max', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Max.php');
     $this->registerRule('unique', 'rule', 'OA_Admin_UI_Rule_Unique', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Unique.php');
     $this->registerRule('equal', 'rule', 'OA_Admin_UI_Rule_Equal', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Equal.php');
     //register jquery rule adaptors
     $this->registerJQueryRuleAdaptor('required', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormRequiredRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryRequiredRule');
     $this->registerJQueryRuleAdaptor('minlength', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMinLengthRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMinLengthRule');
     $this->registerJQueryRuleAdaptor('maxlength', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMaxLengthRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMaxLengthRule');
     $this->registerJQueryRuleAdaptor('email', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormEmailRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryEmailRule');
     $this->registerJQueryRuleAdaptor('numeric', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormDigitsRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryDigitsRule');
     $this->registerJQueryRuleAdaptor('nonzero', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormNonZeroRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryNonZeroRule');
     $this->registerJQueryRuleAdaptor('decimal', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormNumberRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryNumberRule');
     $this->registerJQueryRuleAdaptor('min', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMinRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMinRule');
     $this->registerJQueryRuleAdaptor('max', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMaxRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMaxRule');
     $this->registerJQueryRuleAdaptor('decimalplaces', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormDecimalPlacesAdaptor.php', 'OA_Admin_UI_Rule_QuickFormDecimalPlacesAdaptor');
     $this->registerJQueryRuleAdaptor("unique", MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormUniqueRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryUniqueRule');
     $this->registerJQueryRuleAdaptor("equal", MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormEqualRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryEqualRule');
     //register element decorators
     $this->registerElementDecorator('tag', MAX_PATH . '/lib/OA/Admin/UI/component/decorator/HTMLTagDecorator.php', 'OA_Admin_UI_HTMLTagDecorator');
     $this->registerElementDecorator('process', MAX_PATH . '/lib/OA/Admin/UI/component/decorator/ProcessingDecorator.php', 'OA_Admin_UI_ProcessingDecorator');
     //apply flat class
     $this->setAttribute("class", "flat");
     //trim spaces from all data sent by the user
     $this->applyFilter('__ALL__', 'trim');
     if (!defined('phpAds_installing')) {
         $this->addElement('hidden', 'token', phpAds_SessionGetToken());
         $this->addRule('token', 'Missing request token', 'required');
         $this->addRule('token', 'Invalid request token', 'callback', 'phpAds_SessionValidateToken');
     }
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:50,代码来源:Form.php

示例2: __construct

    /**
     * Constructor
     * @param string $name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param string $layout
     * @param bool $trackSubmit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($name, $method = 'post', $action = '', $target = '', $attributes = array(), $layout = self::LAYOUT_HORIZONTAL, $trackSubmit = true)
    {
        // Default form class.
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        if (isset($attributes['class']) && strpos($attributes['class'], 'form-search') !== false) {
            $layout = 'inline';
        }
        $this->setLayout($layout);
        switch ($layout) {
            case self::LAYOUT_HORIZONTAL:
                $attributes['class'] = 'form-horizontal';
                break;
            case self::LAYOUT_INLINE:
            case self::LAYOUT_BOX:
                $attributes['class'] = 'form-inline';
                break;
        }
        parent::__construct($name, $method, $action, $target, $attributes, $trackSubmit);
        // Modify the default templates
        $renderer =& $this->defaultRenderer();
        // Form template
        $formTemplate = $this->getFormTemplate();
        $renderer->setFormTemplate($formTemplate);
        // Element template
        if (isset($attributes['class']) && $attributes['class'] == 'form-inline') {
            $elementTemplate = ' {label}  {element} ';
            $renderer->setElementTemplate($elementTemplate);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $elementTemplate = ' {label}  {element} ';
            $renderer->setElementTemplate($elementTemplate);
        } else {
            $renderer->setElementTemplate($this->getDefaultElementTemplate());
            // Display a gray div in the buttons
            $templateSimple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($templateSimple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $templateBottom = '<div class="form-actions bottom_actions bg-form">{label} {element}</div>';
            $renderer->setElementTemplate($templateBottom, 'submit_fixed_in_bottom');
            //When you want to group buttons use something like this
            /* $group = array();
                $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
                $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
                $form->addGroup($group, 'buttons_in_action');
               */
            $renderer->setElementTemplate($templateSimple, 'buttons_in_action');
            $templateSimpleRight = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($templateSimpleRight, 'buttons_in_action_right');
        }
        //Set Header template
        $renderer->setHeaderTemplate('<legend>{header}</legend>');
        //Set required field template
        $this->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $noteTemplate = <<<EOT
\t<div class="form-group">
\t\t<div class="col-sm-offset-2 col-sm-10">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($noteTemplate);
    }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:72,代码来源:FormValidator.class.php

示例3: __construct

    /**
     * Constructor
     * @param string $form_name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param bool $track_submit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($form_name = null, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
    {
        // Default form class
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        // Fixing form search
        if (is_array($attributes) && isset($attributes['class'])) {
            //if (strpos($attributes['class'], 'form-search')) {
            if ($attributes['class'] == 'form-search') {
                //    $attributes['class'] = str_replace('form-search', 'form-inline', $attributes['class']);
                $attributes['class'] = 'form-inline';
            }
        }
        // Allow form with no names
        if (empty($form_name)) {
            $form_name = uniqid();
        }
        parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
        // Load some custom elements and rules
        $dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
        $this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('compare_datetime_text', null, 'HTML_QuickForm_Rule_CompareDateTimeText', $dir . 'Rule/CompareDateTimeText.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        /** @var  HTML_QuickForm_Renderer_Default $renderer */
        $renderer =& $this->defaultRenderer();
        // Form template
        $renderer->setFormTemplate($this->getFormTemplate());
        // Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            if (is_array($attributes) && isset($attributes['class']) && $attributes['class'] == 'form-inline') {
                $element_template = $this->getDefaultInlineElementTemplate();
            } else {
                $element_template = $this->getDefaultElementTemplate();
            }
            $renderer->setElementTemplate($element_template);
            // Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            $renderer->setElementTemplate($button_element_template_simple, 'buttons_in_action');
            $button_element_template_simple_right = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($button_element_template_simple_right, 'buttons_in_action_right');
        }
        // Set Header template
        $renderer->setHeaderTemplate('<h2>{header}</h2>');
        //Set required field template
        HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $required_note_template = <<<EOT
\t<div class="form-group">
\t\t<div class="col-sm-2">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($required_note_template);
    }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:92,代码来源:FormValidator.class.php

示例4: __construct

    /**
     * Constructor
     * @param string $form_name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param bool $track_submit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($form_name, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
    {
        // Default form class.
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
        // Load some custom elements and rules
        $dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
        $this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
        $this->registerElementType('date_range_picker', $dir . 'Element/DateRangePicker.php', 'DateRangePicker');
        $this->registerElementType('date_time_picker', $dir . 'Element/DateTimePicker.php', 'DateTimePicker');
        $this->registerElementType('date_picker', $dir . 'Element/DatePicker.php', 'DatePicker');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker_old.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_ajax', $dir . 'Element/select_ajax.php', 'HTML_QuickForm_Select_Ajax');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('style_reset_button', $dir . 'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('datetime', null, 'DateTimeRule', $dir . 'Rule/DateTimeRule.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('mobile_phone_number', null, 'HTML_QuickForm_Rule_Mobile_Phone_Number', $dir . 'Rule/MobilePhoneNumber.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        $renderer =& $this->defaultRenderer();
        //Form template
        $form_template = '<form{attributes}>
<fieldset>
	{content}
	<div class="clear"></div>
</fieldset>
{hidden}
</form>';
        $renderer->setFormTemplate($form_template);
        //Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            $element_template = '
            <div class="control-group {error_class}">
                <label class="control-label" {label-for}>
                    <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
                    {label}
                </label>
                <div class="controls">
                    {element}

                    <!-- BEGIN label_3 -->
                        {label_3}
                    <!-- END label_3 -->

                    <!-- BEGIN label_2 -->
                        <p class="help-block">{label_2}</p>
                    <!-- END label_2 -->

                    <!-- BEGIN error -->
                        <span class="help-inline">{error}</span>
                    <!-- END error -->
                </div>
            </div>';
            $renderer->setElementTemplate($element_template);
            //Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions bg-form">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            //When you want to group buttons use something like this
            /* $group = array();
                $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
                $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
                $form->addGroup($group, 'buttons_in_action');
               */
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:FormValidator.class.php


注:本文中的HTML_QuickForm::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。