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


PHP RequiredFields::setForm方法代码示例

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


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

示例1: singleton

    /**
     * Constructor
     *
     * @param Controller $controller The parent controller, necessary to
     *                               create the appropriate form action tag.
     * @param string $name The method on the controller that will return this
     *                     form object.
     * @param FieldSet|FormField $fields All of the fields in the form - a
     *                                   {@link FieldSet} of {@link FormField}
     *                                   objects.
     * @param FieldSet|FormAction $actions All of the action buttons in the
     *                                     form - a {@link FieldSet} of
     *                                     {@link FormAction} objects
     * @param bool $checkCurrentUser If set to TRUE, it will be checked if a
     *                               the user is currently logged in, and if
     *                               so, only a logout button will be rendered
     * @param string $authenticatorClassName Name of the authenticator class that this form uses.
     */
    function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
    {
        // This is now set on the class directly to make it easier to create subclasses
        // $this->authenticator_class = $authenticatorClassName;
        if (isset($_REQUEST['BackURL'])) {
            $backURL = $_REQUEST['BackURL'];
        } else {
            $backURL = Session::get('BackURL');
        }
        $member = Member::currentUser();
        $label = singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
        if ($checkCurrentUser && $member) {
            $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", $member->FirstName), new TextField("SurnameSignup", "Achternaam", $member->Surname), new TextField("EmailSignup", $label, $member->Email), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password')));
            $actions = new FieldSet(new FormAction("createorupdateaccount", _t('Member.UPDATEDETAILS', "Update your details")), new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
        } else {
            if (!$fields) {
                $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", Session::get('SessionForms.MemberLoginFormWithSignup.FirstNameSignup'), null, $this), new TextField("SurnameSignup", "Achternaam", Session::get('SessionForms.MemberLoginFormWithSignup.SurnameSignup'), null, $this), new TextField("EmailSignup", $label, Session::get('SessionForms.MemberLoginFormWithSignup.EmailSignup'), null, $this), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password')));
                if (Security::$autologin_enabled) {
                    $fields->push(new CheckboxField("RememberSignup", _t('Member.REMEMBERME', "Remember me next time?")));
                }
            }
            if (!$actions) {
                $actions = new FieldSet(new FormAction('createorupdateaccount', _t('Member.BUTTONCREATEACCOUNT', "Create account")));
            }
        }
        if (isset($backURL)) {
            $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
        }
        $requiredFields = parent::__construct($controller, $name, $fields, $actions);
        $validator = new RequiredFields(array("EmailSignup", "FirstNameSignup", "SurnameSignup", "PasswordSignup"));
        $validator->setForm($this);
        $this->validator = $validator;
        // Focus on the email input when the page is loaded
        // Only include this if other form JS validation is enabled
        if ($this->getValidator()->getJavascriptValidationHandler() != 'none') {
            Requirements::customScript(<<<JS
\t\t\t\t(function() {
\t\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_EmailSignup");
\t\t\t\t\tif(el && el.focus) el.focus();
\t\t\t\t})();
JS
);
        }
    }
开发者ID:helpfulrobot,项目名称:sunnysideup-social-integration,代码行数:62,代码来源:MemberLoginFormWithSignup.php


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