/**
  * @param Controller $controller
  * @param Job $job (optional)
  */
 public function __construct($controller, $job = null)
 {
     if ($job) {
         $fields = $job->getFields();
         $required = $job->getValidator();
     } else {
         $fields = singleton('Job')->getFields();
         $required = singleton('Job')->getValidator();
     }
     $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID')));
     if ($job) {
         $jobId->setValue($job->ID);
         $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing')));
     } else {
         $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm')));
     }
     parent::__construct($controller, 'AddJobForm', $fields, $actions, $required);
     $this->setFormAction('JobBoardFormProcessor/doJobForm');
     $this->setFormMethod('POST');
     if ($job) {
         $this->loadDataFrom($job);
     } else {
         $this->enableSpamProtection();
     }
 }
Example #2
1
 public function __construct($id = false)
 {
     parent::__construct();
     $this->add("products");
     $this->name = "form_slider";
     $this->enctype = "multipart/form-data";
     $this->action = URL::current();
     $this->products = ProductDB::getAdminShow();
     if (!$id) {
         $this->text("title", "Название:");
         $this->textarea("description", "Описание:");
         $this->submit("insert_slider", "Сохранить");
     } else {
         $this->add("img");
         $this->add("product_id");
         $this->hidden("id", $id);
         $obj = new SliderDB();
         $obj->load($id);
         $this->text("title", "Название:", $obj->title);
         $img = ProductDB::getCellOnID($obj->product_id, "img");
         $view = new View(Config::DIR_TMPL);
         $this->img = $view->render("img", array("src" => Config::DIR_IMG_PRODUCT . $img), true);
         $this->textarea("description", "Описание:", $obj->description);
         $this->submit("update_slider", "Сохранить");
         $this->product_id = $obj->product_id;
     }
 }
 public function __construct($controller, $name = "CartForm", $cart = null, $template = "Cart")
 {
     $this->cart = $cart;
     $fields = new FieldList(CartEditField::create("Items", "", $this->cart)->setTemplate($template));
     $actions = new FieldList(FormAction::create("updatecart", "Update Cart"));
     parent::__construct($controller, $name, $fields, $actions);
 }
Example #4
0
 /**
  * @param Controller $controller
  * @param String $name
  * @param array $arguments
  */
 public function __construct($controller, $name, $arguments = array())
 {
     /** =========================================
          * @var EmailField $emailField
          * @var TextField $nameField
          * @var FormAction $submit
          * @var Form $form
         ===========================================*/
     /** -----------------------------------------
      * Fields
      * ----------------------------------------*/
     $emailField = EmailField::create('Email', 'Email Address');
     $emailField->addExtraClass('form-control')->setAttribute('placeholder', 'Email')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
     $nameField = TextField::create('Name', 'Name');
     $nameField->setAttribute('placeholder', 'Name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Name</strong>')->setCustomValidationMessage('Please enter your <strong>Name</strong>');
     $fields = FieldList::create($nameField, $emailField);
     /** -----------------------------------------
      * Actions
      * ----------------------------------------*/
     $submit = FormAction::create('Subscribe');
     $submit->setTitle('SIGN UP')->addExtraClass('button');
     $actions = FieldList::create($submit);
     /** -----------------------------------------
      * Validation
      * ----------------------------------------*/
     $required = RequiredFields::create('Name', 'Email');
     $form = Form::create($this, $name, $fields, $actions, $required);
     if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
         $form->loadDataFrom($formData);
     }
     parent::__construct($controller, $name, $fields, $actions, $required);
     $this->setAttribute('data-parsley-validate', true);
     $this->addExtraClass('form');
 }
    public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
    {
        parent::__construct($controller, $name, $fields, $actions, $validator);
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-form/jquery.form.js');
        $name = $this->FormName();
        $action = $this->FormAction();
        $loading = _t('BootstrapAjaxForm.LOADING', 'BootstrapAjaxForm.LOADING');
        $js = <<<JS
(function(\$){
    \$(function(){
        \$('#{$name}').ajaxForm({
            delegation: true,
            target: '#AjaxForm_{$name}',
            beforeSubmit: function(data, form, options){
                \$('#{$name} [type=submit]').prop("disabled", true).html('{$loading}');
            }
\t});
    });
})(jQuery);
JS;
        Requirements::customScript($js, 'BootstrapAjaxForm_Js_' . $this->FormName());
        if (!Director::is_ajax()) {
            $this->setTemplate('BootstrapAjaxForm');
        }
    }
Example #6
0
 /**
  * Class constructor
  *
  */
 public function __construct($plugins)
 {
     parent::__construct('configForm');
     $language = OW::getLanguage();
     $values = OW::getConfig()->getValues('uheader');
     if ($plugins['photo']) {
         $field = new CheckboxField('photo_share');
         $field->setId('photo_share_check');
         $field->setValue($values['photo_share']);
         $this->addElement($field);
         $field = new TextField('photo_album_name');
         $field->setValue(OW::getLanguage()->text('uheader', 'default_photo_album_name'));
         $field->setRequired();
         $this->addElement($field);
     }
     $field = new TextField('cover_height');
     $field->setValue($values['cover_height']);
     $field->addValidator(new IntValidator(self::COVER_MIN_HEIGHT, self::COVER_MAX_HEIGHT));
     $field->setRequired();
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('uheader', 'config_save_label'));
     $this->addElement($submit);
 }
Example #7
0
 public function __construct($ctrl)
 {
     parent::__construct('settings-form');
     $configs = OW::getConfig()->getValues('yncontactimporter');
     $ctrl->assign('configs', $configs);
     $l = OW::getLanguage();
     $miValidator = new IntValidator(1, 999);
     $miValidator->setErrorMessage($l->text('yncontactimporter', 'max_validation_error', array('min' => 1, 'max' => 999)));
     //Contacts per page
     $textField['contact_per_page'] = new TextField('contact_per_page');
     $textField['contact_per_page']->setLabel($l->text('yncontactimporter', 'settings_contact_per_page'))->setValue($configs['contact_per_page'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['contact_per_page']);
     //Maximum invite per times
     $textField['max_invite_per_times'] = new TextField('max_invite_per_times');
     $textField['max_invite_per_times']->setLabel($l->text('yncontactimporter', 'settings_max_invite_per_times'))->setValue($configs['max_invite_per_times'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['max_invite_per_times']);
     //Default invite message
     $textField['default_invite_message'] = new Textarea('default_invite_message');
     $textField['default_invite_message']->setLabel($l->text('yncontactimporter', 'settings_default_invite_message'))->setValue($configs['default_invite_message']);
     $this->addElement($textField['default_invite_message']);
     // Logo width
     $textField['logo_width'] = new TextField('logo_width');
     $textField['logo_width']->setLabel($l->text('yncontactimporter', 'settings_logo_width'))->setValue($configs['logo_width'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['logo_width']);
     // Logo Height
     $textField['logo_height'] = new TextField('logo_height');
     $textField['logo_height']->setLabel($l->text('yncontactimporter', 'settings_logo_height'))->setValue($configs['logo_height'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['logo_height']);
     $submit = new Submit('submit');
     $submit->setValue($l->text('yncontactimporter', 'save_btn_label'));
     $submit->addAttribute('class', 'ow_ic_save ow_positive');
     $this->addElement($submit);
 }
Example #8
0
 public function __construct($controller, $name)
 {
     $product = new Product();
     $title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
     $urlSegment = new TextField('URLSegment', 'URL Segment');
     $menuTitle = new TextField('MenuTitle', 'Navigation Title');
     $sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
     $categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
     $otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
     $model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
     $featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
     $allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
     $price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
     $image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
     $content = new HtmlEditorField('Content', 'Content');
     $fields = new FieldList();
     $fields->add($title);
     //$fields->add($urlSegment);
     //$fields->add($menuTitle);
     //$fields->add($sku);
     $fields->add($categories);
     //$fields->add($otherCategories);
     $fields->add($model);
     $fields->add($featured);
     $fields->add($allow_purchase);
     $fields->add($price);
     $fields->add($image);
     $fields->add($content);
     //$fields = $product->getFrontEndFields();
     $actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
     $requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
 }
Example #9
0
 /**
  * Constructor
  *
  * @param HTMLOutputter $out     output channel
  * @param Profile       $profile profile of user to block
  * @param User_group    $group   group to block user from
  * @param array         $args    return-to args
  */
 function __construct($out = null, $profile = null, $group = null, $args = null)
 {
     parent::__construct($out);
     $this->profile = $profile;
     $this->group = $group;
     $this->args = $args;
 }
Example #10
0
 public function __construct($view, $param)
 {
     parent::__construct();
     $this->add("hornav");
     $this->add("n");
     $this->name = "form_viewgallery";
     $this->enctype = "multipart/form-data";
     $this->action = URL::current();
     $viewgallery_obj = new ViewgalleryDB();
     $viewgallery_obj->load($param["view_id"]);
     $this->hornav = new Hornav();
     $this->hornav->addData("Админпанель", URL::get("menu", "admin"));
     $this->hornav->addData("Галерея", URL::get("viewgallery", "admin"));
     $this->hornav->addData($viewgallery_obj->title, URL::get("listgallery", "admin", array("view_id" => $param["view_id"])));
     if (!$param["gallery_id"]) {
         $this->hornav->addData("Добавить");
         $this->text("title", "Название:", FormProcessor::getSessionData("title"));
         $this->file("img", "Картинка:");
         $this->textarea("meta_desc", "Описание:", FormProcessor::getSessionData("meta_desc"));
         $this->textarea("meta_key", "Ключевые слова:", FormProcessor::getSessionData("meta_key"));
         $this->submit("insert_listgallery", "Сохранить");
     } else {
         $this->hidden("id", $param["gallery_id"]);
         $gallery_obj = new GalleryDB();
         $gallery_obj->load($param["gallery_id"]);
         $this->hornav->addData("Изменить");
         $this->text("title", "Название:", $gallery_obj->title);
         $this->file("img", "Картинка:");
         $this->textarea("meta_desc", "Описание:", $gallery_obj->meta_desc);
         $this->textarea("meta_key", "Ключевые слова:", $gallery_obj->meta_key);
         $this->submit("update_listgallery", "Сохранить");
     }
 }
Example #11
0
 public function __construct($configs, $features)
 {
     parent::__construct('MCOMPOSE_ConfigForm');
     $this->configs = $configs;
     $language = OW::getLanguage();
     $field = new TextField('max_users');
     $field->setRequired();
     $field->setValue($configs['max_users']);
     $this->addElement($field);
     if ($features["friends"]) {
         $field = new CheckboxField('friends_enabled');
         $field->setValue($configs['friends_enabled']);
         $this->addElement($field);
     }
     if ($features["groups"]) {
         $field = new CheckboxField('groups_enabled');
         $field->setValue($configs['groups_enabled']);
         $this->addElement($field);
     }
     if ($features["events"]) {
         $field = new CheckboxField('events_enabled');
         $field->setValue($configs['events_enabled']);
         $this->addElement($field);
     }
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('mcompose', 'admin_save_btn'));
     $this->addElement($submit);
 }
 /**
  * Constructor.
  * @param $submissionId int Submission ID
  * @param $template string Template filename
  */
 function __construct($submissionId, $template)
 {
     parent::__construct($template);
     $this->_submissionId = (int) $submissionId;
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidatorCSRF($this));
 }
Example #13
0
 function __construct($action, $profile)
 {
     parent::__construct($action);
     $this->profile = clone $profile;
     $this->user = common_current_user();
     $this->mirror = SubMirror::pkeyGet(array('subscriber' => $this->user->id, 'subscribed' => $this->profile->id));
 }
Example #14
0
 /**
  * Constructor
  */
 function __construct()
 {
     for ($i = SUBSCRIPTION_OPEN_ACCESS_DELAY_MIN; $i <= SUBSCRIPTION_OPEN_ACCESS_DELAY_MAX; $i++) {
         $this->validDuration[$i] = $i;
     }
     for ($i = SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_MONTHS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_MONTHS_MAX; $i++) {
         $this->validNumMonthsBeforeExpiry[$i] = $i;
     }
     for ($i = SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_WEEKS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_WEEKS_MAX; $i++) {
         $this->validNumWeeksBeforeExpiry[$i] = $i;
     }
     for ($i = SUBSCRIPTION_EXPIRY_REMINDER_AFTER_MONTHS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_AFTER_MONTHS_MAX; $i++) {
         $this->validNumMonthsAfterExpiry[$i] = $i;
     }
     for ($i = SUBSCRIPTION_EXPIRY_REMINDER_AFTER_WEEKS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_AFTER_WEEKS_MAX; $i++) {
         $this->validNumWeeksAfterExpiry[$i] = $i;
     }
     parent::__construct('subscription/subscriptionPolicyForm.tpl');
     // If provided, subscription contact email is valid
     $this->addCheck(new FormValidatorEmail($this, 'subscriptionEmail', 'optional', 'manager.subscriptionPolicies.subscriptionContactEmailValid'));
     // If provided delayed open access duration is valid value
     $this->addCheck(new FormValidatorInSet($this, 'delayedOpenAccessDuration', 'optional', 'manager.subscriptionPolicies.delayedOpenAccessDurationValid', array_keys($this->validDuration)));
     // If provided expiry reminder months before value is valid value
     $this->addCheck(new FormValidatorInSet($this, 'numMonthsBeforeSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numMonthsBeforeSubscriptionExpiryReminderValid', array_keys($this->validNumMonthsBeforeExpiry)));
     // If provided expiry reminder weeks before value is valid value
     $this->addCheck(new FormValidatorInSet($this, 'numWeeksBeforeSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numWeeksBeforeSubscriptionExpiryReminderValid', array_keys($this->validNumWeeksBeforeExpiry)));
     // If provided expiry reminder months after value is valid value
     $this->addCheck(new FormValidatorInSet($this, 'numMonthsAfterSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numMonthsAfterSubscriptionExpiryReminderValid', array_keys($this->validNumMonthsAfterExpiry)));
     // If provided expiry reminder weeks after value is valid value
     $this->addCheck(new FormValidatorInSet($this, 'numWeeksAfterSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numWeeksAfterSubscriptionExpiryReminderValid', array_keys($this->validNumWeeksAfterExpiry)));
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidatorCSRF($this));
 }
 function __construct($controller, $name)
 {
     $org_field = null;
     $current_user = Member::currentUser();
     $current_affiliations = $current_user->getCurrentAffiliations();
     if (!$current_affiliations) {
         $org_field = new TextField('Organization', 'Your Organization Name');
     } else {
         if (count($current_affiliations) > 1) {
             $source = array();
             foreach ($current_affiliations as $a) {
                 $org = $a->Organization();
                 $source[$org->ID] = $org->Name;
             }
             $source['0'] = "-- New One --";
             $ddl = new DropdownField('OrgID', 'Your Organization', $source);
             $ddl->setEmptyString('-- Select Your Organization --');
             $org_field = new FieldGroup();
             $org_field->push($ddl);
             $org_field->push($txt = new TextField('Organization', ''));
             $txt->addExtraClass('new-org-name');
         } else {
             $org_field = new TextField('Organization', 'Your Organization Name', $current_user->getOrgName());
         }
     }
     $fields = new FieldList($org_field, new DropdownField('Industry', 'Your Organization’s Primary Industry', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$industry_options, array('' => '-- Please Select One --'), array('Other' => 'Other Industry (please specify)'))), new TextareaField('OtherIndustry', 'Other Industry'), $org_it_activity = new TextareaField('ITActivity', 'Your Organization’s Primary IT Activity'), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Your Organization’s Primary Location or Headquarters</p>'), $country = new DropdownField('PrimaryCountry', 'Country', CountryCodes::$iso_3166_countryCodes), new TextField('PrimaryState', 'State / Province / Region'), new TextField('PrimaryCity', 'City'), new DropdownField('OrgSize', 'Your Organization Size (All Branches, Locations, Sites)', DeploymentSurveyOptions::$organization_size_options), new CustomCheckboxSetField('OpenStackInvolvement', 'What best describes your Organization’s involvement with OpenStack?<BR>Select All That Apply', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$openstack_involvement_options)));
     $org_it_activity->addExtraClass('hidden');
     $country->setEmptyString('-- Select One --');
     $nextButton = new FormAction('NextStep', '  Next Step  ');
     $actions = new FieldList($nextButton);
     $validator = new RequiredFields();
     Requirements::javascript('surveys/js/deployment_survey_yourorganization_form.js');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Example #16
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('googlelocation');
     $element = new TextField('api_key');
     $element->setValue($configs['api_key']);
     $validator = new StringValidator(0, 40);
     $validator->setErrorMessage($language->text('googlelocation', 'api_key_too_long'));
     $element->addValidator($validator);
     $this->addElement($element);
     $options = array(GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES => $language->text('googlelocation', 'miles'), GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_KM => $language->text('googlelocation', 'kms'));
     $distanseUnits = new Selectbox('distanse_units');
     $distanseUnits->setOptions($options);
     $distanseUnits->setValue(GOOGLELOCATION_BOL_LocationService::getInstance()->getDistanseUnits());
     $distanseUnits->setHasInvitation(false);
     $this->addElement($distanseUnits);
     $restrictions = new Selectbox('country_restriction');
     $restrictions->setValue(!empty($configs['country_restriction']) ? $configs['country_restriction'] : null);
     $restrictions->setOptions($this->countryList);
     $restrictions->setInvitation(OW::getLanguage()->text('googlelocation', 'no_country_restriction'));
     $this->addElement($restrictions);
     $autofill = OW::getConfig()->getValue('googlelocation', 'auto_fill_location_on_search');
     $autoFillLocationOnSearch = new CheckboxField('auto_fill_location_on_search');
     $autoFillLocationOnSearch->setValue(empty($autofill) || $autofill == '0' ? false : $autofill);
     $this->addElement($autoFillLocationOnSearch);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('base', 'edit_button'));
     $this->addElement($submit);
 }
 /**
  * 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 FieldList|FormField $fields All of the fields in the form - a
  *                                   {@link FieldList} of {@link FormField}
  *                                   objects.
  * @param FieldList|FormAction $actions All of the action buttons in the
  *                                     form - a {@link FieldList} of
  */
 function __construct($controller, $name, $fields = null, $actions = null)
 {
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     if (!$fields) {
         $fields = new FieldList();
         // Security/changepassword?h=XXX redirects to Security/changepassword
         // without GET parameter to avoid potential HTTP referer leakage.
         // In this case, a user is not logged in, and no 'old password' should be necessary.
         if (Member::currentUser()) {
             $fields->push(new PasswordField("OldPassword", _t('Member.YOUROLDPASSWORD', "Your old password")));
         }
         $fields->push(new PasswordField("NewPassword1", _t('Member.NEWPASSWORD', "New Password")));
         $fields->push(new PasswordField("NewPassword2", _t('Member.CONFIRMNEWPASSWORD', "Confirm New Password")));
     }
     if (!$actions) {
         $actions = new FieldList(new FormAction("doChangePassword", _t('Member.BUTTONCHANGEPASSWORD', "Change Password")));
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
 function __construct($controller, $name)
 {
     $fields = new FieldSet(new EmailField('Email', _t('Unsubscribe.EMAILADDR', 'Email address')));
     $actions = new FieldSet(new FormAction('sendmeunsubscribelink', _t('Unsubscribe.SENDMEUNSUBSCRIBELINK', 'Send me unsubscribe link')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields(array('Email')));
     $this->disableSecurityToken();
 }
 public function __construct()
 {
     parent::__construct('delete-membership-form');
     $this->setAjaxResetOnSuccess(false);
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlForRoute('membership_delete_type'));
     $lang = OW::getLanguage();
     $typeId = new HiddenField('typeId');
     $typeId->setRequired(true);
     $this->addElement($typeId);
     $newTypeId = new Selectbox('newTypeId');
     $newTypeId->setHasInvitation(false);
     $this->addElement($newTypeId);
     $types = new RadioGroupItemField('type');
     $types->setRequired(true);
     $types->setLabel($lang->text('membership', 'set_membership'));
     $this->addElement($types);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function( data ) {\n                if ( data.result ) {\n                    document.location.reload();\n                }\n            }");
     $script = '$("#btn-confirm-type-delete").click(function(){
         if ( confirm(' . json_encode($lang->text('membership', 'type_delete_confirm')) . ') ) {
              $(this).parents("form:eq(0)").submit();
         }
     });
     ';
     OW::getDocument()->addOnloadScript($script);
 }
 public function __construct()
 {
     parent::__construct('questions_add');
     $language = OW::getLanguage();
     $this->setAjax();
     $this->setAjaxResetOnSuccess(false);
     $field = new Textarea('question');
     $field->addAttribute('maxlength', 500);
     $field->setRequired();
     $field->setHasInvitation(true);
     $field->setInvitation($language->text('questions', 'question_add_text_inv'));
     $field->addAttribute("inv", $language->text('questions', 'question_add_text_inv'));
     $this->addElement($field);
     $field = new CheckboxField('allowAddOprions');
     $field->addAttribute('checked');
     $field->setLabel($language->text('questions', 'question_add_allow_add_opt'));
     $this->addElement($field);
     $field = new QUESTIONS_OptionsField('answers');
     $field->setHasInvitation(true);
     $field->setInvitation($language->text('questions', 'question_add_option_inv'));
     $this->addElement($field);
     $submit = new Submit('save');
     $submit->setValue($language->text('questions', 'question_add_save'));
     $this->addElement($submit);
     if (!OW::getRequest()->isAjax()) {
         OW::getLanguage()->addKeyForJs('questions', 'feedback_question_empty');
         OW::getLanguage()->addKeyForJs('questions', 'feedback_question_min_length');
         OW::getLanguage()->addKeyForJs('questions', 'feedback_question_max_length');
         OW::getLanguage()->addKeyForJs('questions', 'feedback_question_two_apt_required');
         OW::getLanguage()->addKeyForJs('questions', 'feedback_question_dublicate_option');
         OW::getLanguage()->addKeyForJs('questions', 'feedback_option_max_length');
         $this->initJsResponder();
     }
     $this->setAction(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor('QUESTIONS_CTRL_List', 'addQuestion')));
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
Example #22
0
 public function __construct()
 {
     parent::__construct('upload-form');
     $language = OW::getLanguage();
     $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $fileField = new FileField('photo');
     //$fileField->setRequired(true);
     $this->addElement($fileField);
     // album Field
     $albumField = new TextField('album');
     $albumField->setRequired(true);
     $albumField->setHasInvitation(true);
     $albumField->setId('album_input');
     $albumField->setInvitation($language->text('photo', 'create_album'));
     $this->addElement($albumField);
     // description Field
     $descField = new Textarea('description');
     $descField->setHasInvitation(true);
     $descField->setInvitation($language->text('photo', 'describe_photo'));
     $this->addElement($descField);
     $cancel = new Submit('cancel', false);
     $cancel->setValue($language->text('base', 'cancel_button'));
     $this->addElement($cancel);
     $submit = new Submit('submit', false);
     $this->addElement($submit);
 }
 function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $requiredFields = null;
     if ($member && $member->exists()) {
         $fields = $member->getEcommerceFields();
         $passwordField = new ConfirmedPasswordField('Password', _t('MemberForm.PASSWORD', 'Password'));
         if ($member->Password != '') {
             $passwordField->setCanBeEmpty(true);
         }
         //TODO:is this necessary?
         $fields->push(new LiteralField('LogoutNote', "<p class=\"message warning\">" . _t("MemberForm.LOGGEDIN", "You are currently logged in as ") . $member->FirstName . ' ' . $member->Surname . ". " . _t('MemberForm.LOGOUT', 'Click <a href="Security/logout">here</a> to log out.') . "</p>"));
         $fields->push(new HeaderField('Login Details', _t('MemberForm.LOGINDETAILS', 'Login Details'), 3));
         $fields->push($passwordField);
         $requiredFields = new ShopAccountFormValidator($member->getEcommerceRequiredFields());
     } else {
         $fields = new FieldSet();
     }
     if (get_class($controller) == 'AccountPage_Controller') {
         $actions = new FieldSet(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')));
     } else {
         $actions = new FieldSet(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')), new FormAction('proceed', _t('MemberForm.SAVEANDPROCEED', 'Save and proceed to checkout')));
     }
     if ($record = $controller->data()) {
         $record->extend('updateShopAccountForm', $fields, $actions, $requiredFields);
     }
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     if ($member) {
         $member->Password = "";
         //prevents password field from being populated with encrypted password data
         $this->loadDataFrom($member);
     }
 }
 function __construct($controller, $name, $poll)
 {
     if (!$poll) {
         user_error("The poll doesn't exist.", E_USER_ERROR);
     }
     $this->poll = $poll;
     $data = array();
     foreach ($poll->Choices() as $choice) {
         $data[$choice->ID] = $choice->Title;
     }
     if ($poll->MultiChoice) {
         $choiceField = new CheckboxSetField('PollChoices', '', $data);
     } else {
         $choiceField = new OptionsetField('PollChoices', '', $data);
     }
     $fields = new FieldList($choiceField);
     if (PollForm::$show_results_link) {
         $showResultsURL = Director::get_current_page()->Link() . '?poll_results';
         $showResultsLink = new LiteralField('ShowPollLink', '<a class="show-results" href="' . $showResultsURL . '">Show results</a>');
         $fields->push($showResultsLink);
     }
     $actions = new FieldList(new FormAction('submitPoll', 'Submit', null, null, 'button'));
     $validator = new PollForm_Validator('PollChoices');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * Constructor.
  */
 function __construct($site)
 {
     parent::__construct('frontend/pages/userRegister.tpl');
     // Validation checks for this form
     $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true));
     $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired'));
     $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired'));
     $this->addCheck(new FormValidatorUsername($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric'));
     $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthRestriction', '>=', $site->getMinPasswordLength()));
     $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this)));
     $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired'));
     $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired'));
     $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired'));
     // Email checks
     $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired'));
     $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true));
     $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha');
     if ($this->captchaEnabled) {
         $this->addCheck(new FormValidatorReCaptcha($this, Request::getRemoteAddr(), 'common.captcha.error.invalid-input-response'));
     }
     $authDao = DAORegistry::getDAO('AuthSourceDAO');
     $this->defaultAuth = $authDao->getDefaultPlugin();
     if (isset($this->defaultAuth)) {
         $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth)));
     }
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidatorCSRF($this));
 }
 public function __construct($cities, $products, $tankers)
 {
     parent::__construct();
     $this->cities = $cities;
     $this->products = $products;
     $this->tankers = $tankers;
 }
 public function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $requiredFields = null;
     if ($member && $member->exists()) {
         $fields = $member->getMemberFormFields();
         $fields->removeByName('Password');
         //TODO: This can be reverted to be $member->getValidator() as soon as this fix lands in framework
         // (most likely 3.4) https://github.com/silverstripe/silverstripe-framework/pull/5098
         $requiredFields = ShopAccountFormValidator::create();
         $requiredFields->addRequiredField('Surname');
     } else {
         $fields = FieldList::create();
     }
     if (get_class($controller) == 'AccountPage_Controller') {
         $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')));
     } else {
         $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')), FormAction::create('proceed', _t('MemberForm.SaveAndProceed', 'Save and proceed to checkout')));
     }
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     $this->extend('updateShopAccountForm');
     if ($member) {
         $member->Password = "";
         //prevents password field from being populated with encrypted password data
         $this->loadDataFrom($member);
     }
 }
Example #28
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct('update-question-form');
     $this->setAction(OW::getRouter()->urlFor('OCSFAQ_CTRL_Admin', 'editQuestion'));
     $lang = OW::getLanguage();
     $questionId = new HiddenField('questionId');
     $questionId->setRequired(true);
     $this->addElement($questionId);
     $question = new TextField('question');
     $question->setRequired(true);
     $question->setLabel($lang->text('ocsfaq', 'question'));
     $this->addElement($question);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $answer = new WysiwygTextarea('answer', $btnSet);
     $answer->setRequired(true);
     $answer->setLabel($lang->text('ocsfaq', 'answer'));
     $this->addElement($answer);
     $isFeatured = new CheckboxField('isFeatured');
     $isFeatured->setLabel($lang->text('ocsfaq', 'is_featured'));
     $this->addElement($isFeatured);
     $categories = OCSFAQ_BOL_FaqService::getInstance()->getCategories();
     if ($categories) {
         $category = new Selectbox('category');
         foreach ($categories as $cat) {
             $category->addOption($cat->id, $cat->name);
         }
         $category->setLabel($lang->text('ocsfaq', 'category'));
         $this->addElement($category);
     }
     // submit
     $submit = new Submit('update');
     $submit->setValue($lang->text('ocsfaq', 'btn_save'));
     $this->addElement($submit);
 }
 /**
  * Constructor.
  */
 function __construct()
 {
     parent::__construct('user/notificationSettingsForm.tpl');
     // Validation checks for this form
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidatorCSRF($this));
 }
Example #30
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_signup'));
     $this->setAjax();
     $lang = OW::getLanguage();
     $affName = new TextField('name');
     $affName->setRequired(true);
     $affName->setLabel($lang->text('ocsaffiliates', 'affiliate_name'));
     $this->addElement($affName);
     $email = new TextField('email');
     $email->setRequired(true);
     $email->setLabel($lang->text('ocsaffiliates', 'email'));
     $email->addValidator(new EmailValidator());
     $this->addElement($email);
     $password = new PasswordField('password');
     $password->setRequired(true);
     $password->setLabel($lang->text('ocsaffiliates', 'password'));
     $this->addElement($password);
     $payment = new Textarea('payment');
     $payment->setRequired(true);
     $payment->setLabel($lang->text('ocsaffiliates', 'payment_details'));
     $this->addElement($payment);
     if (OW::getConfig()->getValue('ocsaffiliates', 'terms_agreement')) {
         $terms = new CheckboxField('terms');
         $validator = new RequiredValidator();
         $validator->setErrorMessage($lang->text('ocsaffiliates', 'terms_required_msg'));
         $terms->addValidator($validator);
         $this->addElement($terms);
     }
     $submit = new Submit('signup');
     $submit->setValue($lang->text('ocsaffiliates', 'signup_btn'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( !data.result ) {\n                OW.error(data.error);\n            }\n            else {\n                document.location.reload();\n            }\n        }");
 }