/**
  * @return Form|SS_HTTPResponse
  */
 public function EditProfileForm()
 {
     if (!Member::currentUser()) {
         $this->setFlash(_t('EditProfilePage.LoginWarning', 'Please login to edit your profile'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
     $firstName = new TextField('FirstName');
     $firstName->setAttribute('placeholder', _t('EditProfilePage.FirstNamePlaceholder', 'Enter your first name'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $surname = new TextField('Surname');
     $surname->setAttribute('placeholder', _t('EditProfilePage.SurnamePlaceholder', 'Enter your surname'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $email = new EmailField('Email');
     $email->setAttribute('placeholder', _t('EditProfilePage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $jobTitle = new TextField('JobTitle');
     $jobTitle->setAttribute('placeholder', _t('EditProfilePage.JobTitlePlaceholder', 'Enter your job title'))->addExtraClass('form-control');
     $website = new TextField('Website');
     $website->setAttribute('placeholder', _t('EditProfilePage.WebsitePlaceholder', 'Enter your website'))->addExtraClass('form-control');
     $blurb = new TextareaField('Blurb');
     $blurb->setAttribute('placeholder', _t('EditProfilePage.BlurbPlaceholder', 'Enter your blurb'))->addExtraClass('form-control');
     $confirmPassword = new ConfirmedPasswordField('Password', _t('EditProfilePage.PasswordLabel', 'New Password'));
     $confirmPassword->canBeEmpty = true;
     $confirmPassword->setAttribute('placeholder', _t('EditProfilePage.PasswordPlaceholder', 'Enter your password'))->addExtraClass('form-control');
     $fields = new FieldList($firstName, $surname, $email, $jobTitle, $website, $blurb, $confirmPassword);
     $action = new FormAction('SaveProfile', _t('EditProfilePage.SaveProfileText', 'Update Profile'));
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     // Create action
     $validator = new RequiredFields('FirstName', 'Email');
     //Create form
     $form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
     //Populate the form with the current members data
     $Member = Member::currentUser();
     $form->loadDataFrom($Member->data());
     //Return the form
     return $form;
 }
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : Summit::ActiveSummitID();
     Requirements::javascript('summit/javascript/SummitPushNotification.js');
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', $txt = new TextareaField('Message', 'Message'));
     $txt->setAttribute('required', 'true');
     $f->addFieldToTab('Root.Main', $ddl_channel = new DropdownField('Channel', 'Channel', singleton('SummitPushNotification')->dbObject('Channel')->enumValues()));
     $f->addFieldToTab('Root.Main', $ddl_events = new DropdownField('EventID', 'Event', SummitEvent::get()->filter(['Published' => 1, 'SummitID' => $summit_id])->sort('Title', 'ASC')->Map('ID', 'FormattedTitle')));
     $f->addFieldToTab('Root.Main', $ddl_groups = new DropdownField('GroupID', 'Group', Group::get()->sort('Title', 'ASC')->Map('ID', 'Title')));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $ddl_channel->setEmptyString('--SELECT A CHANNEL--');
     $ddl_channel->setAttribute('required', 'true');
     $ddl_events->setEmptyString('--SELECT AN EVENT--');
     $ddl_events->addExtraClass('hidden');
     $ddl_groups->setEmptyString('--SELECT A GROUP--');
     $ddl_groups->addExtraClass('hidden');
     $config = GridFieldConfig_RelationEditor::create(50);
     $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $config->removeComponentsByType('GridFieldAddNewButton');
     $config->addComponent($auto_completer = new CustomGridFieldAddExistingAutocompleter('buttons-before-right'));
     $auto_completer->setResultsFormat('$Title ($Email)');
     $recipients = new GridField('Recipients', 'Member Recipients', $this->Recipients(), $config);
     $f->addFieldToTab('Root.Main', $recipients);
     return $f;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', $dateTimeField = new DatetimeField('Date', $this->fieldLabel('Date')), 'Content');
     $dateTimeField->getDateField()->setConfig('showcalendar', true);
     $fields->addfieldToTab('Root.Main', $abstractField = new TextareaField('Abstract', $this->fieldLabel('Abstract')), 'Content');
     $abstractField->setAttribute('maxlength', '160');
     $abstractField->setRightTitle(_t('DateUpdatePage.AbstractDesc', 'The abstract is used as a summary on the listing pages. It is limited to 160 characters.'));
     $abstractField->setRows(6);
     return $fields;
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new TextareaField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     $field->setColumns(50);
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     return $this->buildDependantRules($rsvp, $question, $field);
 }
Beispiel #5
0
 function ContactUsForm()
 {
     $name = null;
     $email = null;
     $member = Member::currentUser();
     if ($member) {
         $name = $member->Name;
         $email = $member->Email;
     }
     $fields = new FieldList(new TextField('Name', 'Name<span>(*)</span>', $name), new TextField('Email', 'Email<span>(*)</span>', $email), new TextField('Phone', 'Phone'), new TextField('Topic', 'Subject<span>(*)</span>'), $message = new TextareaField('Message', 'Message<span>(*)</span>'), new LiteralField('MessageLimit', '<span style="font-size:9px;margin-left:143px;position:relative;top:-15px;">Enter not more than 500 characters.</span>'), new RecaptchaField('MyCaptcha'));
     $message->setAttribute('maxlength', '500');
     // Create action
     $actions = new FieldList($submit = new FormAction('doContact', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_send.gif');
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Topic', 'Message');
     $validator = null;
     return new Form($this, 'ContactUsForm', $fields, $actions, $validator);
 }
Beispiel #6
0
 function ContactForm()
 {
     // Set up the fields
     $nameField = new TextField('Name', 'Name');
     $nameField->setAttribute('placeholder', 'Name');
     $emailField = new EmailField('Email', 'Email');
     $emailField->setAttribute('placeholder', 'Email');
     $messageField = new TextareaField('Message', 'Message');
     $messageField->setAttribute('placeholder', 'Message');
     // Add the fields
     $fields = new FieldList($nameField, $emailField, $messageField);
     // Create action
     $actions = new FieldList(new FormAction('SendContactForm', 'Send Message'));
     // Create Validators
     $validator = new RequiredFields('Name', 'Email', 'Message');
     // Set up the form
     $form = new Form($this, 'ContactForm', $fields, $actions, $validator);
     $form->setTemplate('ContactForm');
     return $form;
 }
 /**
  * @return static
  */
 public function ContactForm()
 {
     /* -----------------------------------------
         * Scaffolding
        ------------------------------------------*/
     $row = new LiteralField('', '<div class="row">');
     $column = new LiteralField('', '<div class="col-xs-12 col-sm-6">');
     $close = new LiteralField('', '</div>');
     /* -----------------------------------------
         * Fields
        ------------------------------------------*/
     $firstName = new TextField('FirstName', 'First Name');
     $firstName->setAttribute('required', 'required')->addExtraClass('form-control');
     $lastName = new TextField('LastName', 'Last Name');
     $lastName->setAttribute('required', 'required')->addExtraClass('form-control');
     $email = new EmailField('Email', 'Email Address');
     $email->setAttribute('required', 'required')->addExtraClass('form-control');
     $phone = new TextField('Phone', 'Phone Number (optional)');
     $phone->addExtraClass('form-control');
     $message = new TextareaField('Message', 'Message');
     $message->setAttribute('placeholder', _t('ContactPage.MessagePlaceholder', 'Enter your message'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $question = new TextField('Question', '3 &plus; 7 &equals; ?');
     $question->setAttribute('required', 'required')->addExtraClass('form-control');
     $fields = new FieldList($row, $column, $firstName, $close, $column, $lastName, $close, $close, $row, $column, $email, $close, $column, $phone, $close, $close, $message, $question);
     $action = new FormAction('SendContactForm', _t('ContactPage.SubmitText', 'Submit'));
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     $validator = new RequiredFields('FirstName', 'LastName', 'Email', 'Message');
     $form = Form::create($this, 'ContactForm', $fields, $actions, $validator);
     if ($formData = Session::get('FormInfo.Form_ContactForm.data')) {
         $form->loadDataFrom($formData);
     }
     return $form;
 }
 public function PostForm()
 {
     $fields = FieldList::create();
     if ($this->Options()->UserTitle) {
         $fields->push($title = TextField::create('Title', _t('MicroBlog.TITLE', 'Title')));
         $title->setAttribute('placeholder', _t('MicroBlog.TITLE_PLACEHOLDER', 'Title (optional)'));
     }
     $fields->push($taf = new TextareaField('Content', _t('MicroBlog.POST', 'Post')));
     $taf->setAttribute('placeholder', _t('MicroBlog.CONTENT_PLACEHOLDER', 'Add content here, eg text or a link'));
     $taf->setRows(3);
     $taf->addExtraClass('expandable');
     $taf->addExtraClass('postContent');
     $taf->addExtraClass('preview');
     $public = CheckboxField::create('PublicUsers', 'Public users', Config::inst()->get('TimelineController', 'default_public'));
     $loggedIn = CheckboxField::create('LoggedInUsers', "Logged in users", Config::inst()->get('TimelineController', 'default_logged_in'));
     $groups = Group::get()->filter("ParentID", 0);
     $specificGroups = null;
     if (class_exists('Multisites')) {
         $specificGroups = Multisites::inst()->getCurrentSite()->TargetedGroups();
     } else {
         $specificGroups = SiteConfig::current_site_config()->TargetedGroups();
     }
     if (count($specificGroups)) {
         $groups = $specificGroups;
     }
     $members = Member::get();
     if ($members->count() > $this->ajaxMemberLimit) {
         $member = AjaxSelect2Field::create('Members', "To")->setConfig('classToSearch', 'Member')->setConfig('multiple', true)->setConfig('searchFields', array('FirstName', 'Surname', 'Email'))->setConfig('resultsLimit', $this->ajaxMemberLimit);
     } else {
         $member = MultiSelect2Field::create('Members', "To", $members->map()->toArray())->setMultiple(true);
     }
     $group = MultiSelect2Field::create("Groups", "To Groups", $groups->map()->toArray())->setMultiple(true);
     $fields->push($public);
     $fields->push($loggedIn);
     $fields->push($member);
     $fields->push($group);
     $target = $this->getTargetFilter();
     if ($target) {
         $fields->push(HiddenField::create('PostTarget', '', $target));
     }
     $actions = new FieldList(new FormAction('savepost', _t('MicroBlog.SAVE', 'Add')));
     $form = new Form($this, 'PostForm', $fields, $actions);
     $this->extend('updatePostForm', $form);
     return $form;
 }