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


PHP HTMLForm::add_constraint方法代码示例

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


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

示例1: build_form

    private function build_form()
    {
        $security_config = SecurityConfig::load();
        $this->form = new HTMLForm('adminForm', '', false);
        $fieldset = new FormFieldsetHTML('adminAccount', $this->lang['admin.account']);
        $this->form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('display_name', LangLoader::get_message('display_name', 'user-common'), '', array('maxlength' => 100, 'required' => true, 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100, $this->lang['admin.login.length']))));
        $fieldset->add_field(new FormFieldMailEditor('email', $this->lang['admin.email'], '', array('required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('custom_login', LangLoader::get_message('login.custom', 'user-common'), false, array('description' => LangLoader::get_message('login.custom.explain', 'user-common'), 'events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else {
					HTMLForms.getField("login").disable();
				}'))));
        $fieldset->add_field(new FormFieldTextEditor('login', LangLoader::get_message('login', 'user-common'), '', array('required' => true, 'hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists())));
        $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['admin.password'], '', array('description' => StringVars::replace_vars($this->lang['admin.password.explanation'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length(), StringVars::replace_vars($this->lang['admin.password.length'], array('number' => $security_config->get_internal_password_min_length()))), new FormFieldConstraintPasswordStrength())));
        $fieldset->add_field($repeatPassword = new FormFieldPasswordEditor('repeatPassword', $this->lang['admin.password.repeat'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $this->form->add_constraint(new FormConstraintFieldsEquality($password, $repeatPassword));
        $fieldset->add_field(new FormFieldCheckbox('createSession', $this->lang['admin.connectAfterInstall'], true));
        $fieldset->add_field(new FormFieldCheckbox('autoconnect', $this->lang['admin.autoconnect'], true));
        $action_fieldset = new FormFieldsetSubmit('actions');
        $back = new FormButtonLinkCssImg($this->lang['step.previous'], InstallUrlBuilder::website(), 'fa fa-arrow-left');
        $action_fieldset->add_element($back);
        $this->submit_button = new FormButtonSubmitCssImg($this->lang['step.next'], 'fa fa-arrow-right', 'admin');
        $action_fieldset->add_element($this->submit_button);
        $this->form->add_fieldset($action_fieldset);
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:32,代码来源:InstallCreateAdminController.class.php

示例2: build_form

 private function build_form()
 {
     $this->form = new HTMLForm('smtp_config');
     $fieldset = new FormFieldsetHTML('mail_properties', $this->lang['mail.title']);
     $this->form->add_fieldset($fieldset);
     $sender_mail = new FormFieldMailEditor('sender_mail', $this->lang['mail.sender_mail'], '');
     $fieldset->add_field($sender_mail);
     $fieldset->add_field(new FormFieldTextEditor('sender_name', $this->lang['mail.sender_name'], '', array(), array(new FormFieldConstraintNotEmpty())));
     $recipient_mail = new FormFieldMailEditor('recipient_mail', $this->lang['mail.recipient_mail'], '');
     $fieldset->add_field($recipient_mail);
     $fieldset->add_field(new FormFieldTextEditor('recipient_name', $this->lang['mail.recipient_name'], '', array(), array(new FormFieldConstraintNotEmpty())));
     $fieldset->add_field(new FormFieldTextEditor('mail_subject', $this->lang['mail.subject'], '', array(), array(new FormFieldConstraintNotEmpty())));
     $fieldset->add_field(new FormFieldMultiLineTextEditor('mail_content', $this->lang['mail.content'], ''));
     $fieldset = new FormFieldsetHTML('send_configuration', $this->lang['mail.smtp_config'], array('description' => $this->lang['mail.smtp_config.explain']));
     $this->form->add_fieldset($fieldset);
     $fieldset->add_field(new FormFieldCheckbox('use_smtp', $this->lang['mail.use_smtp'], false, array('events' => array('click' => 'if ($FF("use_smtp").getValue()) { $FFS("smtp_configuration").enable(); } else { $FFS("smtp_configuration").disable(); }'))));
     $fieldset = new FormFieldsetHTML('smtp_configuration', $this->lang['mail.smtp_configuration'], array('disabled' => true));
     $this->form->add_fieldset($fieldset);
     $fieldset->add_field(new FormFieldTextEditor('smtp_host', $this->lang['mail.smtp.host'], '', array('disabled' => true), array(new FormFieldConstraintRegex('`^[a-z0-9-]+(?:\\.[a-z0-9-]+)*$`i'))));
     $fieldset->add_field(new FormFieldTextEditor('smtp_port', $this->lang['mail.smtp.port'], 25, array('disabled' => true), array(new FormFieldConstraintIntegerRange(0, 65535))));
     $fieldset->add_field(new FormFieldTextEditor('smtp_login', $this->lang['mail.smtp.login'], '', array('disabled' => true), array(new FormFieldConstraintNotEmpty())));
     $fieldset->add_field(new FormFieldPasswordEditor('smtp_password', $this->lang['mail.smtp.password'], '', array('disabled' => true)));
     $select_option = new FormFieldSelectChoiceOption($this->lang['mail.smtp.secure_protocol.none'], 'none');
     $fieldset->add_field(new FormFieldSimpleSelectChoice('secure_protocol', $this->lang['mail.smtp.secure_protocol'], $select_option, array($select_option, new FormFieldSelectChoiceOption($this->lang['mail.smtp.secure_protocol.tls'], 'tls'), new FormFieldSelectChoiceOption($this->lang['mail.smtp.secure_protocol.ssl'], 'ssl')), array('disabled' => true)));
     $this->submit_button = new FormButtonDefaultSubmit();
     $this->form->add_button($this->submit_button);
     $this->form->add_constraint(new FormConstraintFieldsInequality($recipient_mail, $sender_mail));
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:28,代码来源:SandboxMailController.class.php

示例3: build_form

    private function build_form(HTTPRequestCustom $request)
    {
        $security_config = SecurityConfig::load();
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('add_member', LangLoader::get_message('members.add-member', 'admin-user-common'));
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists())));
        $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist())));
        $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else {
					HTMLForms.getField("login").disable();
				}'))));
        $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('required' => true, 'hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists())));
        $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        if ($security_config->are_login_and_email_forbidden_in_password()) {
            $form->add_constraint(new FormConstraintFieldsInequality($email, $password));
            $form->add_constraint(new FormConstraintFieldsInequality($login, $password));
        }
        $fieldset->add_field(new FormFieldRanksSelect('rank', $this->lang['rank'], FormFieldRanksSelect::MEMBER));
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:35,代码来源:AdminMemberAddController.class.php

示例4: build_form

    private function build_form(HTTPRequestCustom $request)
    {
        $common_lang = LangLoader::get('common');
        $date_lang = LangLoader::get('date-common');
        $event_content = $this->get_event()->get_content();
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('event', $this->lang['calendar.titles.event']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('title', $common_lang['form.title'], $event_content->get_title(), array('required' => true)));
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
        $fieldset->add_field(CalendarService::get_categories_manager()->get_select_categories_form_field('category_id', LangLoader::get_message('category', 'categories-common'), $event_content->get_category_id(), $search_category_children_options));
        $fieldset->add_field(new FormFieldRichTextEditor('contents', $common_lang['form.contents'], $event_content->get_contents(), array('rows' => 15, 'required' => true)));
        $fieldset->add_field($start_date = new FormFieldDateTime('start_date', $this->lang['calendar.labels.start_date'], $this->get_event()->get_start_date(), array('required' => true)));
        $fieldset->add_field($end_date = new FormFieldDateTime('end_date', $this->lang['calendar.labels.end_date'], $this->get_event()->get_end_date(), array('required' => true)));
        $form->add_constraint(new FormConstraintFieldsDifferenceSuperior($start_date, $end_date));
        $fieldset->add_field(new FormFieldSimpleSelectChoice('repeat_type', $this->lang['calendar.labels.repeat_type'], $event_content->get_repeat_type(), array(new FormFieldSelectChoiceOption($this->lang['calendar.labels.repeat.never'], CalendarEventContent::NEVER), new FormFieldSelectChoiceOption($date_lang['every_day'], CalendarEventContent::DAILY), new FormFieldSelectChoiceOption($date_lang['every_week'], CalendarEventContent::WEEKLY), new FormFieldSelectChoiceOption($date_lang['every_month'], CalendarEventContent::MONTHLY), new FormFieldSelectChoiceOption($date_lang['every_year'], CalendarEventContent::YEARLY)), array('events' => array('change' => '
			if (HTMLForms.getField("repeat_type").getValue() != "' . CalendarEventContent::NEVER . '") {
				HTMLForms.getField("repeat_number").enable();
			} else {
				HTMLForms.getField("repeat_number").disable();
			}'))));
        $fieldset->add_field(new FormFieldNumberEditor('repeat_number', $this->lang['calendar.labels.repeat_number'], $event_content->get_repeat_number(), array('min' => 1, 'max' => 150, 'hidden' => $event_content->get_repeat_type() == CalendarEventContent::NEVER), array(new FormFieldConstraintIntegerRange(1, 150))));
        $fieldset->add_field(new FormFieldShortMultiLineTextEditor('location', $this->lang['calendar.labels.location'], $event_content->get_location()));
        $fieldset->add_field(new FormFieldCheckbox('registration_authorized', $this->lang['calendar.labels.registration_authorized'], $event_content->is_registration_authorized(), array('events' => array('click' => '
			if (HTMLForms.getField("registration_authorized").getValue()) {
				HTMLForms.getField("max_registered_members").enable();
				HTMLForms.getField("last_registration_date_enabled").enable();
				jQuery("#' . __CLASS__ . '_register_authorizations").show();
			} else {
				HTMLForms.getField("max_registered_members").disable();
				HTMLForms.getField("last_registration_date_enabled").disable();
				jQuery("#' . __CLASS__ . '_register_authorizations").hide();
			}'))));
        $fieldset->add_field(new FormFieldNumberEditor('max_registered_members', $this->lang['calendar.labels.max_registered_members'], $event_content->get_max_registered_members(), array('description' => $this->lang['calendar.labels.max_registered_members.explain'], 'hidden' => !$event_content->is_registration_authorized()), array(new FormFieldConstraintRegex('`^[0-9]+$`i'))));
        $fieldset->add_field(new FormFieldCheckbox('last_registration_date_enabled', $this->lang['calendar.labels.last_registration_date_enabled'], $event_content->is_last_registration_date_enabled(), array('hidden' => !$event_content->is_registration_authorized(), 'events' => array('click' => '
			if (HTMLForms.getField("last_registration_date_enabled").getValue()) {
				HTMLForms.getField("last_registration_date").enable();
			} else {
				HTMLForms.getField("last_registration_date").disable();
			}'))));
        $fieldset->add_field(new FormFieldDateTime('last_registration_date', $this->lang['calendar.labels.last_registration_date'], $event_content->get_last_registration_date(), array('hidden' => !$event_content->is_last_registration_date_enabled())));
        $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($this->lang['calendar.authorizations.display_registered_users'], CalendarEventContent::DISPLAY_REGISTERED_USERS_AUTHORIZATION), new ActionAuthorization($this->lang['calendar.authorizations.register'], CalendarEventContent::REGISTER_AUTHORIZATION)));
        $auth_settings->build_from_auth_array($event_content->get_register_authorizations());
        $auth_setter = new FormFieldAuthorizationsSetter('register_authorizations', $auth_settings, array('hidden' => !$event_content->is_registration_authorized()));
        $fieldset->add_field($auth_setter);
        if (!$this->is_contributor_member()) {
            $fieldset->add_field(new FormFieldCheckbox('approved', $common_lang['form.approve'], $event_content->is_approved()));
        }
        $this->build_contribution_fieldset($form);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:57,代码来源:CalendarFormController.class.php

示例5: build_form

    private function build_form()
    {
        $security_config = SecurityConfig::load();
        $form = new HTMLForm(__CLASS__);
        $this->member_extended_fields_service = new MemberExtendedFieldsService($form);
        $fieldset = new FormFieldsetHTML('registration', $this->lang['registration']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldHTML('validation_method', $this->get_accounts_validation_method_explain()));
        $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists())));
        $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist())));
        $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], FormFieldCheckbox::CHECKED));
        $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('description' => $this->lang['login.custom.explain'], 'events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else { 
					HTMLForms.getField("login").disable();
				}'))));
        $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists())));
        $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        if ($security_config->are_login_and_email_forbidden_in_password()) {
            $form->add_constraint(new FormConstraintFieldsInequality($email, $password));
            $form->add_constraint(new FormConstraintFieldsInequality($login, $password));
        }
        $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main'));
        $form->add_fieldset($options_fieldset);
        $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], GeneralConfig::load()->get_site_timezone(), array('description' => $this->lang['timezone.choice.explain'])));
        if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) {
            $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user_accounts_config->get_default_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes()))));
            $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme() . '" title="' . $this->lang['theme.preview'] . '" alt="' . $this->lang['theme.preview'] . '" class="preview-img" />'));
        }
        $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], ContentFormattingConfig::load()->get_default_editor()));
        $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user_accounts_config->get_default_lang(), array('check_authorizations' => true)));
        $this->member_extended_fields_service->display_form_fields();
        $agreement_text = FormatingHelper::second_parse($this->user_accounts_config->get_registration_agreement());
        if (!empty($agreement_text)) {
            $agreement_fieldset = new FormFieldsetHTML('agreement_fieldset', $this->lang['agreement']);
            $form->add_fieldset($agreement_fieldset);
            $agreement = new FormFieldHTML('agreement.required', $this->lang['agreement.agree.required'] . '<br /><br />');
            $agreement_fieldset->add_field($agreement);
            $agreement = new FormFieldHTML('agreement', '<div id="id-message-helper" class="notice user-agreement">' . $agreement_text . '</div>');
            $agreement_fieldset->add_field($agreement);
            $agreement_fieldset->add_field(new FormFieldCheckbox('agree', $this->lang['agreement.agree'], FormFieldCheckbox::UNCHECKED, array('required' => $this->lang['agreement.agree.required'])));
        }
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:55,代码来源:UserRegistrationController.class.php

示例6: build_form

 private function build_form()
 {
     $security_config = SecurityConfig::load();
     $form = new HTMLForm(__CLASS__);
     $fieldset = new FormFieldsetHTML('fieldset', $this->lang['change-password']);
     $form->add_fieldset($fieldset);
     $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password.new'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
     $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
     $this->submit_button = new FormButtonDefaultSubmit();
     $form->add_button($this->submit_button);
     $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
     $this->form = $form;
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:13,代码来源:UserChangeLostPasswordController.class.php

示例7: build_form

 private function build_form()
 {
     $security_config = SecurityConfig::load();
     $form = new HTMLForm('sandboxForm');
     // FIELDSET
     $fieldset = new FormFieldsetHTML('fieldset_1', 'Fieldset');
     $form->add_fieldset($fieldset);
     $fieldset->set_description('Ceci est ma description');
     // SINGLE LINE TEXT
     $fieldset->add_field(new FormFieldTextEditor('text', 'Champ texte', 'toto', array('maxlength' => 25, 'description' => 'Contraintes lettres, chiffres et tiret bas'), array(new FormFieldConstraintRegex('`^[a-z0-9_ ]+$`i'))));
     $fieldset->add_field(new FormFieldTextEditor('textdisabled', 'Champ désactivé', '', array('maxlength' => 25, 'description' => 'désactivé', 'disabled' => true)));
     $fieldset->add_field(new FormFieldUrlEditor('siteweb', 'Site web', 'http://www.phpboost.com/index.php', array('description' => 'Url valide')));
     $fieldset->add_field(new FormFieldMailEditor('mail', 'Mail', 'team.hein@phpboost.com', array('description' => 'Mail valide')));
     $fieldset->add_field(new FormFieldMailEditor('mail_multiple', 'Mail multiple', 'team.hein@phpboost.com, test@phpboost.com', array('description' => 'Mails valides, séparés par une virgule', 'multiple' => true)));
     $fieldset->add_field(new FormFieldTelEditor('tel', 'Numéro de téléphone', '0123456789', array('description' => 'Numéro de téléphone valide')));
     $fieldset->add_field(new FormFieldTextEditor('text2', 'Champ texte2', 'toto2', array('maxlength' => 25, 'description' => 'Champs requis rempli', 'required' => true)));
     $fieldset->add_field(new FormFieldTextEditor('text3', 'Champ requis', '', array('maxlength' => 25, 'description' => 'Champs requis vide', 'required' => true)));
     $fieldset->add_field(new FormFieldNumberEditor('number', 'Nombre requis', 20, array('min' => 0, 'max' => 1000, 'description' => 'Intervalle 0 à 1000', 'required' => true), array(new FormFieldConstraintIntegerRange(0, 1000))));
     $fieldset->add_field(new FormFieldNumberEditor('age', 'Age', 20, array('min' => 10, 'max' => 100, 'description' => 'Intervalle 10 à 100'), array(new FormFieldConstraintIntegerRange(10, 100))));
     $fieldset->add_field(new FormFieldDecimalNumberEditor('decimal', 'Nombre décimal', 5.5, array('min' => 0, 'step' => 0.1)));
     // RANGE
     $fieldset->add_field($password = new FormFieldRangeEditor('range', 'Longueur', 4, array('min' => 1, 'max' => 10, 'description' => 'Slider horizontal')));
     // PASSWORD
     $fieldset->add_field($password = new FormFieldPasswordEditor('password', 'Mot de passe', 'aaaaaa', array('description' => 'Minimum ' . $security_config->get_internal_password_min_length() . ' caractères'), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()))));
     $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', 'Confirmation du mot de passe', 'aaaaaa', array('description' => 'Minimum ' . $security_config->get_internal_password_min_length() . ' caractères'), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()))));
     // SHORT MULTI LINE TEXT
     $fieldset->add_field(new FormFieldShortMultiLineTextEditor('short_multi_line_text', 'Champ texte multi lignes moyen', 'titi', array('rows' => 7, 'required' => true)));
     // MULTI LINE TEXT
     $fieldset->add_field(new FormFieldMultiLineTextEditor('multi_line_text', 'Champ texte multi lignes', 'toto', array('rows' => 6, 'cols' => 47, 'description' => 'Description', 'required' => true)));
     // RICH TEXT
     $fieldset->add_field(new FormFieldRichTextEditor('rich_text', 'Champ texte riche dans éditeur', 'toto <strong>tata</strong>', array('required' => true)));
     //Checkbox
     $fieldset->add_field(new FormFieldMultipleCheckbox('multiple_check_box', 'Plusieurs checkbox', array(), array(new FormFieldMultipleCheckboxOption('meet', 'la viande'), new FormFieldMultipleCheckboxOption('fish', 'le poisson')), array('required' => true)));
     // RADIO
     $default_option = new FormFieldRadioChoiceOption('Choix 1', '1');
     $fieldset->add_field(new FormFieldRadioChoice('radio', 'Choix énumération', '', array($default_option, new FormFieldRadioChoiceOption('Choix 2', '2')), array('required' => true)));
     // CHECKBOX
     $fieldset->add_field(new FormFieldCheckbox('checkbox', 'Case à cocher', FormFieldCheckbox::CHECKED));
     // SELECT
     $fieldset->add_field(new FormFieldSimpleSelectChoice('select', 'Liste déroulante', '', array(new FormFieldSelectChoiceOption('', ''), new FormFieldSelectChoiceOption('Choix 1', '1'), new FormFieldSelectChoiceOption('Choix 2', '2'), new FormFieldSelectChoiceOption('Choix 3', '3'), new FormFieldSelectChoiceGroupOption('Groupe 1', array(new FormFieldSelectChoiceOption('Choix 4', '4'), new FormFieldSelectChoiceOption('Choix 5', '5'))), new FormFieldSelectChoiceGroupOption('Groupe 2', array(new FormFieldSelectChoiceOption('Choix 6', '6'), new FormFieldSelectChoiceOption('Choix 7', '7')))), array('required' => true)));
     // SELECT MULTIPLE
     $fieldset->add_field(new FormFieldMultipleSelectChoice('multiple_select', 'Liste déroulante multiple', array('1', '2'), array(new FormFieldSelectChoiceOption('Choix 1', '1'), new FormFieldSelectChoiceOption('Choix 2', '2'), new FormFieldSelectChoiceOption('Choix 3', '3')), array('required' => true)));
     $fieldset->add_field(new FormFieldTimezone('timezone', 'TimeZone', 'UTC+0'));
     $fieldset->add_field(new FormFieldAjaxSearchUserAutoComplete('user_completition', 'Auto complétion utilisateurs', ''));
     $fieldset->add_element(new FormButtonButton('Envoyer'));
     $fieldset2 = new FormFieldsetHTML('fieldset2', 'Fieldset 2');
     $form->add_fieldset($fieldset2);
     // CAPTCHA
     $fieldset2->add_field(new FormFieldCaptcha('captcha'));
     // HIDDEN
     $fieldset2->add_field(new FormFieldHidden('hidden', 'hidden'));
     // FREE FIELD
     $fieldset2->add_field(new FormFieldFree('free', 'Champ libre', 'Valeur champ libre', array()));
     // DATE
     $fieldset2->add_field(new FormFieldDate('date', 'Date', null, array('required' => true)));
     // DATE TIME
     $fieldset2->add_field(new FormFieldDateTime('date_time', 'Heure', null, array('required' => true)));
     // COLOR PICKER
     $fieldset2->add_field(new FormFieldColorPicker('color', 'Couleur', '#CC99FF'));
     // SEARCH
     $fieldset2->add_field(new FormFieldSearch('search', 'Recherche', ''));
     // FILE PICKER
     $fieldset2->add_field(new FormFieldFilePicker('file', 'Fichier'));
     // MULTIPLE FILE PICKER
     $fieldset2->add_field(new FormFieldMultipleFilePicker('multiple_files', 'Plusieurs Fichiers'));
     // UPLOAD FILE
     $fieldset2->add_field(new FormFieldUploadFile('upload_file', 'Lien vers un fichier', '', array('required' => true)));
     // UPLOAD PICTURE FILE
     $fieldset2->add_field(new FormFieldUploadPictureFile('upload_picture_file', 'Lien vers une image', '', array('required' => true)));
     // AUTH
     $fieldset3 = new FormFieldsetHTML('fieldset3', 'Autorisations');
     $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization('Action 1', 1, 'Autorisations pour l\'action 1'), new ActionAuthorization('Action 2', 2)));
     $auth_settings->build_from_auth_array(array('r1' => 3, 'r0' => 2, 'm1' => 1, '1' => 2));
     $auth_setter = new FormFieldAuthorizationsSetter('auth', $auth_settings);
     $fieldset3->add_field($auth_setter);
     $form->add_fieldset($fieldset3);
     // VERTICAL FIELDSET
     $vertical_fieldset = new FormFieldsetVertical('fieldset4');
     $vertical_fieldset->set_description('Ceci est ma description');
     $form->add_fieldset($vertical_fieldset);
     $vertical_fieldset->add_field(new FormFieldTextEditor('alone', 'Texte', 'fieldset séparé'));
     $vertical_fieldset->add_field(new FormFieldCheckbox('cbhor', 'A cocher', FormFieldCheckbox::UNCHECKED));
     // HORIZONTAL FIELDSET
     $horizontal_fieldset = new FormFieldsetHorizontal('fieldset5');
     $horizontal_fieldset->set_description('Ceci est ma description');
     $form->add_fieldset($horizontal_fieldset);
     $horizontal_fieldset->add_field(new FormFieldTextEditor('texthor', 'Texte', 'fieldset séparé', array('required' => true)));
     $horizontal_fieldset->add_field(new FormFieldCheckbox('cbvert', 'A cocher', FormFieldCheckbox::CHECKED));
     // BUTTONS
     $buttons_fieldset = new FormFieldsetSubmit('buttons');
     $buttons_fieldset->add_element(new FormButtonReset());
     $this->preview_button = new FormButtonSubmit('Prévisualiser', 'preview', 'alert("Voulez-vous vraiment prévisualiser ?")');
     $buttons_fieldset->add_element($this->preview_button);
     $this->submit_button = new FormButtonDefaultSubmit();
     $buttons_fieldset->add_element($this->submit_button);
     $buttons_fieldset->add_element(new FormButtonButton('Bouton', 'alert("coucou");'));
     $form->add_fieldset($buttons_fieldset);
     // FORM CONSTRAINTS
     $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
     return $form;
//.........这里部分代码省略.........
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:101,代码来源:SandboxFormController.class.php

示例8: build_form

    private function build_form()
    {
        $security_config = SecurityConfig::load();
        $activated_auth_types = AuthenticationService::get_activated_types_authentication();
        $form = new HTMLForm(__CLASS__);
        $this->member_extended_fields_service = new MemberExtendedFieldsService($form);
        $fieldset = new FormFieldsetHTML('edit_profile', $this->lang['profile.edit']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], $this->user->get_display_name(), array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists($this->user->get_id()))));
        $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], $this->user->get_email(), array('required' => true), array(new FormFieldConstraintMailExist($this->user->get_id()))));
        $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], !$this->user->get_show_email()));
        $fieldset->add_field(new FormFieldCheckbox('delete_account', $this->lang['delete-account'], FormFieldCheckbox::UNCHECKED));
        if (AppContext::get_current_user()->is_admin()) {
            $manage_fieldset = new FormFieldsetHTML('member_management', $this->lang['member-management']);
            $form->add_fieldset($manage_fieldset);
            $manage_fieldset->add_field(new FormFieldCheckbox('approbation', $this->lang['approbation'], $this->internal_auth_infos['approved']));
            $manage_fieldset->add_field(new FormFieldRanksSelect('rank', $this->lang['rank'], $this->user->get_level()));
            $manage_fieldset->add_field(new FormFieldGroups('groups', $this->lang['groups'], $this->user->get_groups()));
        }
        $connect_fieldset = new FormFieldsetHTML('connect', $this->lang['connection']);
        $form->add_fieldset($connect_fieldset);
        $more_than_one_authentication_type = count($activated_auth_types) > 1;
        $has_custom_login = $this->user->get_email() !== $this->internal_auth_infos['login'];
        if ($more_than_one_authentication_type) {
            if (in_array(PHPBoostAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) {
                $connect_fieldset->add_field(new FormFieldFree('internal_auth', $this->lang['internal_connection'] . ' <i class="fa fa-success"></i>', '<a onclick="javascript:HTMLForms.getField(\'custom_login\').enable();' . ($has_custom_login ? 'HTMLForms.getField(\'login\').enable();' : '') . 'HTMLForms.getField(\'password\').enable();HTMLForms.getField(\'password_bis\').enable();HTMLForms.getField(\'old_password\').enable();">' . LangLoader::get_message('edit', 'common') . '</a>'));
            } else {
                $connect_fieldset->add_field(new FormFieldFree('internal_auth', $this->lang['internal_connection'] . ' <i class="fa fa-error"></i>', '<a onclick="javascript:HTMLForms.getField(\'custom_login\').enable();HTMLForms.getField(\'password\').enable();HTMLForms.getField(\'password_bis\').enable();">Créer une authentification interne</a>'));
            }
        }
        $connect_fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], $has_custom_login, array('description' => $this->lang['login.custom.explain'], 'hidden' => $more_than_one_authentication_type, 'events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else {
					HTMLForms.getField("login").disable();
				}'))));
        $connect_fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], $has_custom_login ? $this->internal_auth_infos['login'] : preg_replace('/\\s+/', '', $this->user->get_display_name()), array('required' => true, 'hidden' => $more_than_one_authentication_type || !$has_custom_login, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists($this->user->get_id()))));
        $connect_fieldset->add_field(new FormFieldPasswordEditor('old_password', $this->lang['password.old'], '', array('description' => $this->lang['password.old.explain'], 'hidden' => $more_than_one_authentication_type)));
        $connect_fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'hidden' => $more_than_one_authentication_type), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $connect_fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('hidden' => $more_than_one_authentication_type), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        if ($security_config->are_login_and_email_forbidden_in_password()) {
            $form->add_constraint(new FormConstraintFieldsInequality($email, $password));
            $form->add_constraint(new FormConstraintFieldsInequality($login, $password));
        }
        if (in_array('facebook', $activated_auth_types)) {
            if (in_array(FacebookAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) {
                $connect_fieldset->add_field(new FormFieldFree('fb_auth', $this->lang['fb_connection'] . ' <i class="fa fa-success"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'dissociate', 'fb')->absolute() . '">' . $this->lang['dissociate_account'] . '</a>'));
            } else {
                $connect_fieldset->add_field(new FormFieldFree('fb_auth', $this->lang['fb_connection'] . ' <i class="fa fa-error"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'associate', 'fb')->absolute() . '">' . $this->lang['associate_account'] . '</a>'));
            }
        }
        if (in_array('google', $activated_auth_types)) {
            if (in_array(GoogleAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) {
                $connect_fieldset->add_field(new FormFieldFree('google_auth', $this->lang['google_connection'] . ' <i class="fa fa-success"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'dissociate', 'google')->absolute() . '">' . $this->lang['dissociate_account'] . '</a>'));
            } else {
                $connect_fieldset->add_field(new FormFieldFree('google_auth', $this->lang['google_connection'] . ' <i class="fa fa-error"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'associate', 'google')->absolute() . '">' . $this->lang['associate_account'] . '</a>'));
            }
        }
        $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main'));
        $form->add_fieldset($options_fieldset);
        $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], $this->user->get_timezone(), array('description' => $this->lang['timezone.choice.explain'])));
        if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) {
            $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user->get_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes()))));
            $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme($this->user->get_theme()) . '" alt="' . $this->lang['theme.preview'] . '" title="' . $this->lang['theme.preview'] . '" class="preview-img" />'));
        }
        $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], $this->user->get_editor()));
        $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user->get_locale(), array('check_authorizations' => true)));
        if (AppContext::get_current_user()->is_admin()) {
            $fieldset_punishment = new FormFieldsetHTML('punishment_management', $this->lang['punishment-management']);
            $form->add_fieldset($fieldset_punishment);
            $fieldset_punishment->add_field(new FormFieldMemberCaution('user_warning', $this->lang['caution'], $this->user->get_warning_percentage()));
            $fieldset_punishment->add_field(new FormFieldMemberSanction('user_readonly', $this->lang['readonly'], $this->user->get_delay_readonly()));
            $fieldset_punishment->add_field(new FormFieldMemberSanction('user_ban', $this->lang['banned'], $this->user->get_delay_banned()));
        }
        $this->member_extended_fields_service->display_form_fields($this->user->get_id());
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:86,代码来源:UserEditProfileController.class.php


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