/** * @param Controller $controller * @param String $name * @param array $arguments */ public function __construct($controller, $name, $arguments = array()) { /** ----------------------------------------- * Fields * ----------------------------------------*/ /** @var EmailField $email */ $email = EmailField::create('Email', 'Email Address'); $email->addExtraClass('form-control')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>'); $fields = FieldList::create($email); /** ----------------------------------------- * Actions * ----------------------------------------*/ $actions = FieldList::create(FormAction::create('Subscribe')->setTitle('Subscribe')->addExtraClass('btn btn-primary')); /** ----------------------------------------- * Validation * ----------------------------------------*/ $required = RequiredFields::create('Email'); /** @var Form $form */ $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'); }
/** * @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 createValidator() { $validator = RequiredFields::create('PaymentMethod'); $this->extend('updateValidator', $validator); $validator->setForm($this); return $validator; }
public function __construct($controller, $name = "PostagePaymentForm") { // Get delivery data and postage areas from session $delivery_data = Session::get("Commerce.DeliveryDetailsForm.data"); $country = $delivery_data['DeliveryCountry']; $postcode = $delivery_data['DeliveryPostCode']; $postage_areas = $controller->getPostageAreas($country, $postcode); // Loop through all postage areas and generate a new list $postage_array = array(); foreach ($postage_areas as $area) { $area_currency = new Currency("Cost"); $area_currency->setValue($area->Cost); $postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")"; } $postage_id = Session::get('Commerce.PostageID') ? Session::get('Commerce.PostageID') : 0; // Setup postage fields $postage_field = CompositeField::create(HeaderField::create("PostageHeader", _t('Commerce.Postage', "Postage")), OptionsetField::create("PostageID", _t('Commerce.PostageSelection', 'Please select your prefered postage'), $postage_array)->setValue($postage_id))->setName("PostageFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50"); // Get available payment methods and setup payment $payment_methods = SiteConfig::current_site_config()->PaymentMethods(); // Deal with payment methods if ($payment_methods->exists()) { $payment_map = $payment_methods->map('ID', 'Label'); $payment_value = $payment_methods->filter('Default', 1)->first()->ID; } else { $payment_map = array(); $payment_value = 0; } $payment_field = CompositeField::create(HeaderField::create('PaymentHeading', _t('Commerce.Payment', 'Payment'), 2), OptionsetField::create('PaymentMethodID', _t('Commerce.PaymentSelection', 'Please choose how you would like to pay'), $payment_map, $payment_value))->setName("PaymentFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50"); $fields = FieldList::create(CompositeField::create($postage_field, $payment_field)->setName("PostagePaymentFields")->addExtraClass("units-row")->addExtraClass("line")); $back_url = $controller->Link("billing"); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('doContinue', _t('Commerce.PaymentDetails', 'Enter Payment Details'))->addExtraClass('btn')->addExtraClass('commerce-action-next')->addExtraClass('btn-green')); $validator = RequiredFields::create(array("PostageID", "PaymentMethod")); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * RegistrationForm constructor * * @param Controller $controller * @param String $name * @param array $arguments */ public function __construct($controller, $name, $arguments = array()) { /** ----------------------------------------- * Fields * ----------------------------------------*/ /** @var TextField $firstName */ $firstName = TextField::create('FirstName'); $firstName->setAttribute('placeholder', 'Enter your first name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>First Name</strong>')->setCustomValidationMessage('Please enter your <strong>First Name</strong>'); /** @var EmailField $email */ $email = EmailField::create('Email'); $email->setAttribute('placeholder', 'Enter your email address')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>'); /** @var PasswordField $password */ $password = PasswordField::create('Password'); $password->setAttribute('placeholder', 'Enter your password')->setCustomValidationMessage('Please enter your <strong>Password</strong>')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Password</strong>'); $fields = FieldList::create($email, $password); /** ----------------------------------------- * Actions * ----------------------------------------*/ $actions = FieldList::create(FormAction::create('Register')->setTitle('Register')->addExtraClass('btn--primary')); /** ----------------------------------------- * Validation * ----------------------------------------*/ $required = RequiredFields::create('FirstName', 'Email', 'Password'); /** @var Form $form */ $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 form--registration'); }
/** * EmailVerificationLoginForm is the same as MemberLoginForm with the following changes: * - The code has been cleaned up. * - A form action for users who have lost their verification email has been added. * * We add fields in the constructor so the form is generated when instantiated. * * @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 {@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 */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field); $email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus'); $password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password')); $authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this); $remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true); if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) { $fields = FieldList::create($authentication_method_field); $actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = FieldList::create($authentication_method_field, $email_field, $password_field); if (Security::config()->remember_username) { $email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email')); } else { // Some browsers won't respect this attribute unless it's added to the form $this->setAttribute('autocomplete', 'off'); $email_field->setAttribute('autocomplete', 'off'); } } if (!$actions) { $actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>')); } } if (isset($_REQUEST['BackURL'])) { $fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL'])); } // Reduce attack surface by enforcing POST requests $this->setFormMethod('POST', true); parent::__construct($controller, $name, $fields, $actions); $this->setValidator(RequiredFields::create('Email', 'Password')); }
/** * Creates a form to set a password * * @return Form */ public function SetPasswordForm() { if (!Member::currentUser()) { return false; } $form = Form::create($this->owner, FieldList::create(PasswordField::create('Password', 'Password'), PasswordField::Create('Password_confirm', 'Confirm password'), HiddenField::create('BackURL', '', $this->owner->requestVar('BackURL'))), FieldList::create(FormAction::create('doSetPassword', 'Set my password')), RequiredFields::create('Password', 'Password_confirm')); return $form; }
public function PersonalRegisterForm() { $fields = FieldList::create(array(EmailField::create('Email', '电子邮件'), ConfirmedPasswordField::create('Password', '密码'), TextField::create('FullName', '姓名'), TextField::create('IDCard', '身份证号码'), TextField::create('Phone', '联系电话'), DropdownField::create('OrganizationID', '所属单位名称', Organization::get()->map('ID', 'company_name'))->setEmptyString('请选择'))); $actions = FieldList::create(array(FormAction::create('doRegisterPersonal', '提交'))); $required = RequiredFields::create(array('Email', 'Password', 'FullName', 'IDCard', 'Phone', 'OrganizationID')); $form = new Form($this, __FUNCTION__, $fields, $actions, $required); return $form; }
public function ApplicationForm() { $fields = FieldList::create(TextField::create('Name', 'Full name'), EmailField::create('Email', 'Email address'), PhoneNumberField::create('Phone', 'Contact Phone number'), DropdownField::create('JobID', 'Which job are you applying for?', $this->AvailableJobs()->map('ID', 'Title'))->setEmptyString('(Select)'), TextareaField::create('Application', 'Enter your experience and skills')); $actions = FieldList::create(FormAction::create('processApplication', 'Apply')); $validator = RequiredFields::create(array('Name', 'Email', 'Phone', 'JobID', 'Application')); $form = Form::create($this, 'ApplicationForm', $fields, $actions, $validator); return $form; }
function TypoForm() { $array = array('green', 'yellow', 'blue', 'pink', 'orange'); $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField')); $textAreaField->setColumns(45); $form->setMessage('warning message', 'warning'); return $form; }
public function CommentForm() { $form = Form::create($this, __FUNCTION__, FieldList::create(TextField::create('Name', '')->setAttribute('placeholder', 'Name*')->addExtraClass('form-control'), EmailField::create('Email', '')->setAttribute('placeholder', 'Email*')->addExtraClass('form-control'), TextareaField::create('Comment', '')->setAttribute('placeholder', 'Comment*')->addExtraClass('form-control')), FieldList::create(FormAction::create('handleComment', 'Post Comment')->setUseButtonTag(true)->addExtraClass('btn btn-default-color btn-lg')), RequiredFields::create('Name', 'Email', 'Comment')); $form->addExtraClass('form-style'); $data = Session::get("FormData.{$form->getName()}.data"); //using the tirnary operator if $data exist... return $data ? $form->loadDataFrom($data) : $form; }
/** * Set the required form fields for this payment record, taking those * defined in Payment in to account. */ public static function getCMSValidator() { //Get required fields from Courier DataObject. $parent_required = is_array(parent::getCMSValidator()) ? parent::getCMSValidator() : array(); //Specify our own required fields. $required = array("txn_id"); //Return the required fields. return RequiredFields::create(array_merge($parent_required, $required)); }
public function CommentForm() { $form = Form::create($this, __FUNCTION__, FieldList::create(TextField::create('Name', ''), EmailField::create('Email', ''), TextareaField::create('Comment', '')), FieldList::create(FormAction::create('handleComment', 'Post Comment')->setUseButtonTag(true)->addExtraClass('btn btn-default-color btn-lg')), RequiredFields::create('Name', 'Email', 'Comment'))->addExtraClass('form-style'); foreach ($form->Fields() as $field) { $field->addExtraClass('form-control')->setAttribute('placeholder', $field->getName() . '*'); } $data = Session::get("FormData.{$form->getName()}.data"); return $data ? $form->loadDataFrom($data) : $form; }
/** * Set the required form fields for this gateway, taking those * defined in Gateway in to account. */ public static function getCMSValidator() { //Get required fields from Gateway DataObject. $parent_required = is_array(parent::getCMSValidator()) ? parent::getCMSValidator() : array(); //Specify our own required fields. $required = array("EmailAddress", "PDTToken"); //Return the required fields. return RequiredFields::create(array_merge($parent_required, $required)); }
/** * Form used for adding or editing addresses */ public function AddressForm() { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 2), TextField::create('FirstName', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('Surname', _t('Checkout.Surname', 'Surname')), CheckboxField::create('Default', _t('Checkout.DefaultAddress', 'Default Address?'))->setRightTitle(_t('Checkout.Optional', 'Optional')))->setName("PersonalFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 2), TextField::create('Address1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('Address2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t('Checkout.Optional', 'Optional')), TextField::create('City', _t('Checkout.City', 'City')), TextField::create('PostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('Country', _t('Checkout.Country', 'Country'))->setAttribute("class", 'countrydropdown dropdown'))->setName("AddressFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $fields = FieldList::create(HiddenField::create("ID"), HiddenField::create("OwnerID"), CompositeField::create($personal_fields, $address_fields)->setName("DeliveryFields")->addExtraClass('line')->addExtraClass('units-row')); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $this->owner->Link('addresses') . '" class="btn btn-red">' . _t('Checkout.Cancel', 'Cancel') . '</a>'), FormAction::create('doSaveAddress', _t('Checkout.Add', 'Add'))->addExtraClass('btn')->addExtraClass('btn-green')); $validator = RequiredFields::create(array('FirstName', 'Surname', 'Address1', 'City', 'PostCode', 'Country')); $form = Form::create($this->owner, "AddressForm", $fields, $actions, $validator); return $form; }
public function Form() { $fields = FieldList::create(CompositeField::create(array(TextField::create('FirstName', 'First Name')->addExtraClass('col-sm-6 col-xs-12'), TextField::create('LastName', 'Last Name')->addExtraClass('col-sm-6 col-xs-12'), TextField::create('Email', 'Email Address')->addExtraClass('col-sm-6 col-xs-12'), TextField::create('Contact', 'Contact Number')->addExtraClass('col-sm-6 col-xs-12'), TextField::create('CallingTime', 'Best Calling Time')->addExtraClass('col-sm-6 col-xs-12'), TextField::create('LiquidCapital', 'Liquid Capital')->addExtraClass('col-sm-6 col-xs-12'), DateField::create('TimeStart', 'Time Frame to Start')->setConfig('showcalendar', 'true')->addExtraClass('col-sm-6 col-xs-12')))->addExtraClass('info'), CompositeField::create(array(TextareaField::create('Area', 'In what area are you looking to invest in a franchise?')->addExtraClass('col-sm-12'), TextareaField::create('Experience', 'Business & Relevant Experience')->addExtraClass('col-sm-12'), TextareaField::create('Hear', 'How did you hear about the Beard Papa’s franchise')->addExtraClass('col-sm-12'), TextareaField::create('Message', 'Message')->addExtraClass('col-sm-12')))->addExtraClass('questions')); $actions = FieldList::create(FormAction::create('Send', 'Send')->addExtraClass('btn btn-primary')); $requires = RequiredFields::create('FirstName', 'LastName', 'Email', 'Contact', 'CallingTime', 'LiquidCapital', 'TimeStart', 'Area', 'Experience', 'Hear'); $form = new Form($this, __FUNCTION__, $fields, $actions, $requires); if ($formData = Session::get('FranchiseData')) { $form->loadDataFrom($formData); } return $form; }
/** * @return mixed * The contact us form */ public function ContactForm() { $fields = FieldList::create(TextField::create('Name', _t('Contact.Name', 'Name')), TextField::create('Email', _t('Contact.Email', 'Email')), TextField::create('Phone', _t('Contact.Phone', 'Phone Number')), TextField::create('Subject', _t('Contact.Subject', 'Subject')), TextareaField::create('Message', _t('Contact.Message', 'Message'))); $actions = FieldList::create(FormAction::create('Submit', _t('Contact.Submit', 'Submit'))); $required = RequiredFields::create('Name', 'Email', 'Message'); $form = new Form($this, __FUNCTION__, $fields, $actions, $required); if (Session::get('Contact')) { $form->loadDataFrom(Session::get('Contact')); } return $form; }
public function ContactForm() { $FieldList = FieldList::create(array($name = TextField::create('Name', 'Your name'), $mail = EmailField::create('Email', 'Your email address'), $subj = TextField::create('Subject', 'Subject'), $rece = DropdownField::create('Receiver', 'Who to contact', Contact::getReceivers()), LiteralField::create('', '<div class="clearfix"></div>'), $area = TextareaField::create('Content', 'Message'))); $Action = FieldList::create($btn = FormAction::create('HandleForm', 'Submit')); $btn->addExtraClass('button-green-full'); $Required = RequiredFields::create(array('Name', 'Email', 'Receiver', 'Subject', 'Content')); /** @var Form $Form */ $Form = Form::create($this, 'ContactForm', $FieldList, $Action, $Required); $Form->flashMessage = Session::get('ThanksMessage'); return $Form; }
/** * PresentationMediaUploadForm constructor. * @param Controller $controller * @param string $name * @param SummitEvent $presentation */ public function __construct($controller, $name, SummitEvent $presentation) { $this->presentation = $presentation; $fields = FieldList::create(FileAttachmentField::create('Slide', 'File')->setFolderName('/presentation-media/')->setPermissions(['upload' => true, 'detach' => false, 'delete' => false])); $actions = FieldList::create(FormAction::create('doUpload', 'Upload File')); $validator = RequiredFields::create(['Slide']); parent::__construct($controller, $name, $fields, $actions, $validator); $material = $presentation->MaterialType('PresentationSlide'); if ($material) { $this->loadDataFrom($material); } }
/** * FoxyStripePurchaseForm constructor. * @param Controller $controller * @param string $name * @param FieldList|null $fields * @param FieldList|null $actions * @param null $validator * @param null $product * @param null $siteConfig */ public function __construct($controller, $name, FieldList $fields = null, FieldList $actions = null, $validator = null, $product = null, $siteConfig = null) { $this->setProduct($product); $this->setSiteConfig($siteConfig); $fields = $fields != null && $fields->exists() ? $this->getProductFields($fields) : $this->getProductFields(FieldList::create()); $actions = $actions != null && $actions->exists() ? $this->getProductActions($actions) : $this->getProductActions(FieldList::create()); $validator = !empty($validator) || $validator != null ? $validator : RequiredFields::create(); parent::__construct($controller, $name, $fields, $actions, $validator); //have to call after parent::__construct() $this->setAttribute('action', FoxyCart::FormActionURL()); $this->disableSecurityToken(); }
public function Form() { $fields = FieldList::create(TextField::create('Name', 'Name')->addExtraClass('col-sm-12 col-xs-12'), TextField::create('Email', 'Email')->addExtraClass('col-sm-12 col-xs-12'), TextField::create('Subject', 'Subject')->addExtraClass('col-sm-12 col-xs-12'), TextareaField::create('Message', 'Message')->addExtraClass('col-sm-12 col-xs-12')); $actions = FieldList::create(FormAction::create('Send', 'Send')->addExtraClass('btn btn-primary')); $requires = RequiredFields::create('Name', 'Email', 'Subject', 'Message'); $form = new Form($this, __FUNCTION__, $fields, $actions, $requires); $form->addExtraClass('col-sm-10 col-sm-offset-1 col-xs-12'); if ($formData = Session::get('ContactData')) { $form->loadDataFrom($formData); } return $form; }
public function ContestEntryForm() { $validator = RequiredFields::create('Name', 'Email', 'Title', 'myCaptcha'); $recaptchaField = RecaptchaField::create('myCaptcha', 'Are You a Robot?'); $recaptchaField->jsOptions = array('theme' => 'clean'); // optional // Create fields $fields = new FieldList(Textfield::create('Name'), Textfield::create('Email'), Textfield::create('Title'), HTMLEditorField::create('Content'), $recaptchaField); // Create actions $actions = new FieldList(FormAction::create('doContestEnter', 'Submit')->addExtraClass('btn btn-secondary')); return Form::create($this, 'ContestEntryForm', $fields, $actions); }
/** * PresentationLinkToForm constructor. * @param Controller $controller * @param string $name * @param SummitEvent $presentation */ public function __construct($controller, $name, SummitEvent $presentation) { $this->presentation = $presentation; $fields = FieldList::create(TextField::create('Link', 'Link (URL) for your online presentation:')); $actions = FieldList::create(FormAction::create('saveLink', 'Save Link')); $validator = RequiredFields::create(['Link']); parent::__construct($controller, $name, $fields, $actions, $validator); $material = $presentation->MaterialType('PresentationSlide'); if ($material) { $this->loadDataFrom($material); } }
/** * Contructor * @param type $controller * @param type $name */ public function __construct($controller, $name) { //Fields $fields = singleton('EventRegistration')->getFrontEndFields(); //Actions $actions = FieldList::create(FormAction::create("doRegister")->setTitle("Register")); //Validator $validator = RequiredFields::create(array('Name', 'Email')); $this->addExtraClass('EventRegistrationForm'); $this->addExtraClass($name); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * Contructor * @param type $controller * @param type $name */ function __construct($controller, $name) { //Fields $fields = FieldList::create(TextField::create('Name', 'Name'), TextField::create('PayersName', "Payer's Name"), TextField::create('Email', 'Email'), DropdownField::create('NumberOfTickets', 'Number of Tickets', array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10')), TextareaField::create("Notes"), HiddenField::create('EventID')); //Actions $actions = FieldList::create(FormAction::create("doRegister")->setTitle("Register")); //Validator $validator = RequiredFields::create(array('Name', 'Email')); $this->addExtraClass('PaymentRegistrationForm'); $this->addExtraClass($name); parent::__construct($controller, $name, $fields, $actions, $validator); }
public function createValidator() { $validator = RequiredFields::create(); $items = $this->order->Items(); if ($items) { foreach ($items as $item) { $validator->addRequiredField('Quantity[' . $item->ID . ']'); } } $this->extend('updateValidator', $validator); $validator->setForm($this); return $validator; }
/** * Adds variations specific fields to the CMS. */ public function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.Attributes', array(HeaderField::create('Applicable Attribute Types'), CheckboxSetField::create('StaticAttributeTypes', 'Static Attribute Types', ProductAttributeType::get()->map("ID", "Title")), LiteralField::create('staticattributehelp', '<p>Select any attributes that apply to this product and click Save.</p>'), HeaderField::create('Attributes'))); foreach ($this->owner->StaticAttributeTypes() as $type) { $source = $this->getValuesClosure($type->ID); $newValFields = FieldList::create(array(TextField::create('Value', 'Label'), HiddenField::create('TypeID', '', $type->ID))); $newValReq = RequiredFields::create('Value'); $valuesField = HasStaticAttributes_CheckboxSetField::create('StaticAttributeValues-' . $type->ID, $type->Title, $source()); $valuesField->setValue($this->owner->StaticAttributeValues()->filter('TypeID', $type->ID)->getIDList()); $valuesField->useAddNew('ProductAttributeValue', $source, $newValFields, $newValReq); $fields->addFieldToTab('Root.Attributes', $valuesField); } }
/** * @param Controller $controller * @param String $name * @param array $arguments */ public function __construct($controller, $name, $arguments = array()) { /** ----------------------------------------- * Fields * ----------------------------------------*/ $clearfix = LiteralField::create('', '<div class="clearfix"></div><!-- /.clearfix -->'); /** @var TextField $firstName */ $firstName = TextField::create('FirstName', _t('ContactForm.FirstName', 'First Name')); $firstName->setAttribute('data-parsley-required-message', _t('ContactForm.FirstNameRequiredMessage', 'Please enter your <strong>First Name</strong>'))->setAttribute('autocomplete', 'fname given-name')->setCustomValidationMessage(_t('ContactForm.FirstNameRequiredMessage', 'Please enter your <strong>First Name</strong>')); /** @var TextField $lastName */ $lastName = TextField::create('LastName', _t('ContactForm.LastName', 'Last Name')); $lastName->setAttribute('data-parsley-required-message', _t('ContactForm.LastNameRequiredMessage', 'Please enter your <strong>Last Name</strong>'))->setAttribute('autocomplete', 'lname family-name')->setCustomValidationMessage(_t('ContactForm.LastNameRequiredMessage', 'Please enter your <strong>Last Name</strong>')); /** @var EmailField $email */ $email = EmailField::create('Email', _t('ContactForm.Email', 'Email Address')); $email->setAttribute('data-parsley-required-message', _t('ContactForm.EmailRequiredMessage', 'Please enter your <strong>Email</strong>'))->setAttribute('autocomplete', 'email')->setCustomValidationMessage(_t('ContactForm.EmailRequiredMessage', 'Please enter your <strong>Email</strong>')); /** @var TextField $phone */ $phone = TextField::create('Phone', _t('ContactForm.Phone', 'Phone Number (optional)'))->setAttribute('autocomplete', 'tel'); $phone->addExtraClass('form-control'); /** @var TextField $suburb */ $suburb = TextField::create('Suburb', _t('ContactForm.Suburb', 'Suburb')); $suburb->setAttribute('data-parsley-required-message', _t('ContactForm.SuburbRequiredMessage', 'Please enter your <strong>Suburb</strong>'))->setAttribute('autocomplete', 'region')->setCustomValidationMessage(_t('ContactForm.SuburbRequiredMessage', 'Please enter your <strong>Suburb</strong>')); /** @var TextField $city */ $city = TextField::create('City', _t('ContactForm.City', 'City')); $city->setAttribute('data-parsley-required-message', _t('ContactForm.CityRequiredMessage', 'Please enter your <strong>City</strong>'))->setAttribute('autocomplete', 'city')->setCustomValidationMessage(_t('ContactForm.CityRequiredMessage', 'Please enter your <strong>City</strong>')); /** @var TextareaField $message */ $message = TextareaField::create('Message', _t('ContactForm.Message', 'Message')); $message->setAttribute('placeholder', _t('ContactForm.MessagePlaceholder', 'Enter your message'))->setAttribute('data-parsley-required-message', _t('ContactForm.MessageRequiredMessage', 'Please enter your <strong>Message</strong>'))->setCustomValidationMessage(_t('ContactForm.MessageRequiredMessage', 'Please enter your <strong>Message</strong>')); /** @var LiteralField $reCaptcha */ $reCaptcha = LiteralField::create('', ''); if (isset($arguments['ReCaptchaSiteKey']) && isset($arguments['ReCaptchaSecretKey'])) { $reCaptcha = LiteralField::create('ReCaptcha', '<div class="recaptcha g-recaptcha" data-sitekey="' . $arguments['ReCaptchaSiteKey'] . '"></div>'); } $fields = FieldList::create($firstName, $lastName, $clearfix, $email, $phone, $message, $clearfix, $reCaptcha); /** ----------------------------------------- * Actions * ----------------------------------------*/ $actions = FieldList::create(FormAction::create('Submit')->setTitle(_t('ContactForm.Submit', 'Submit'))->addExtraClass('btn--primary')); /** ----------------------------------------- * Validation * ----------------------------------------*/ $required = RequiredFields::create('FirstName', 'LastName', 'Email', 'Message'); /** @var Form $form */ $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->setAttribute('autocomplete', 'on'); $this->addExtraClass('form form--contact'); }
public function __construct($controller, $name, $poll) { if (!$poll) { user_error("The poll doesn't exist.", E_USER_ERROR); } $this->poll = $poll; $data = $poll->Answers()->map('ID', 'Title'); if ($poll->Multiple) { $choiceField = CheckboxSetField::create('PollChoices', $poll->Question, $data); } else { $choiceField = OptionsetField::create('PollChoices', '', $data); } $fields = FieldList::create($choiceField); $actions = FieldList::create(FormAction::create('submitPoll', 'Verstuur')); $validator = RequiredFields::create(array('PollChoices')); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * LocatorForm constructor. * @param Controller $controller * @param string $name */ public function __construct(Controller $controller, $name) { $fields = FieldList::create(TextField::create('Address')->setTitle('')->setAttribute('placeholder', 'address or zip code')); $pageCategories = Locator::locator_categories_by_locator($controller->data()->ID); if ($pageCategories && $pageCategories->count() > 0) { $categories = false; } else { $categories = Locator::get_all_categories(); } if ($categories) { $categoriesField = DropdownField::create('CategoryID')->setTitle('')->setEmptyString('All Categories')->setSource($categories->map()); $fields->push($categoriesField); } $actions = FieldList::create(FormAction::create('doFilterLocations')->setTitle('Search')); $validator = RequiredFields::create(); parent::__construct($controller, $name, $fields, $actions, $validator); }