/**
  * 
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $searchState = $gridField->State->GridFieldSearchRelation;
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     $value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
     // Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
     $searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation)) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
 /**
  * Return the payment form fields that should
  * be shown on the checkout order form for the
  * payment type. Example: for {@link DPSPayment},
  * this would be a set of fields to enter your
  * credit card details.
  *
  * @return FieldList
  */
 function getPaymentFormFields()
 {
     $fieldList = new FieldList(array(new LiteralField("DPSPXPost_Logo", $this->Config()->get("dps_logo_and_link")), $creditCardField = new EcommerceCreditCardField("DPSPXPost_CreditCard", _t("DpsPxPost.DPSPXPOST_CREDITCARD", "Card Number"), $this->CardNumber), $nameOnCardField = new TextField("DPSPXPost_NameOnCard", _t("DpsPxPost.DPSPXPOST_NAMEONCARD", "Name on Card"), $this->NameOnCard), $expiryDateField = new ExpiryDateField("DPSPXPost_ExpiryDate", _t("DpsPxPost.DPSPXPOST_EXPIRYDATE", "Expiry Date"), $this->ExpiryDate), $cvvNumberField = new TextField("DPSPXPost_CVVNumber", _t("DpsPxPost.DPSPXPOST_CVVNumber", "Security Number"), $this->CVVNumber)));
     $nameOnCardField->setAttribute("maxlength", "40");
     $cvvNumberField->setAttribute("maxlength", "4");
     $cvvNumberField->setAttribute("size", "4");
     $cvvNumberField->setAttribute("autocomplete", "off");
     return $fieldList;
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Get values from the config system, to act as placeholders for site config properties.
     $config = Config::inst();
     $editable = $config->get('GoogleAPI', 'config_in_cms');
     if (!$editable) {
         // No extra config fields if this is disabled.
         return $fields;
     }
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIExternalProxy', 'Proxy to call external apis'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'external_proxy'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIClientID', 'Google API Client ID'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'client_id'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIProfileID', 'Google API Profile ID (not Property ID)'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'profile_id'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIApplicationName', 'Google API Application Name'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'application_name'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIServiceAccount', 'Google API Service Account'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'service_account'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIPrivateKeyFile', 'Google API Path to Private Key file (relative to site root)'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'private_key_file'));
     $fields->addFieldToTab('Root.GoogleAPI', $fld = new TextField('GoogleAPIScopes', 'Google API Scopes'));
     $fld->setAttribute('placeholder', $config->get('GoogleAPI', 'scopes'));
     return $fields;
 }
Пример #4
0
 /**
  * @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;
 }
 function __construct($controller, $name)
 {
     $fields = new FieldList(array($t1 = new TextField('ExternalOrderId', 'Eventbrite Order #'), $checkbox = new CheckboxField('SharedContactInfo', 'Allow to share contact info?')));
     $t1->setAttribute('placeholder', 'Enter your Eventbrite order #');
     $t1->addExtraClass('event-brite-order-number');
     $attendees = Session::get('attendees');
     if (count($attendees) > 0) {
         $t1->setValue(Session::get('ExternalOrderId'));
         $t1->setReadonly(true);
         $checkbox->setValue(intval(Session::get('SharedContactInfo')) === 1);
         $fields->add(new LiteralField('ctrl1', 'Current Order has following registered attendees, please select one:'));
         $options = array();
         foreach ($attendees as $attendee) {
             $ticket_external_id = intval($attendee['ticket_class_id']);
             $ticket_type = SummitTicketType::get()->filter('ExternalId', $ticket_external_id)->first();
             if (is_null($ticket_type)) {
                 continue;
             }
             $options[$attendee['id']] = $attendee['profile']['name'] . ' (' . $ticket_type->Name . ')';
         }
         $attendees_ctrl = new OptionSetField('SelectedAttendee', '', $options);
         $fields->add($attendees_ctrl);
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn_clear = new FormAction('clearSummitAttendeeInfo', 'Clear'), $btn = new FormAction('saveSummitAttendeeInfo', 'Done'));
         $btn->addExtraClass('btn btn-default active');
         $btn_clear->addExtraClass('btn btn-danger active');
     } else {
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn = new FormAction('saveSummitAttendeeInfo', 'Get Order'));
         $btn->addExtraClass('btn btn-default active');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * @param TextField $lat
  * @return GeoCodeField
  */
 public function setLat($lat)
 {
     $this->lat = new TextField($lat);
     $this->lat->setAttribute('disabled', 'disabled');
     $this->lat->setAttribute('placeholder', _t('GeoCodeField.Lat', ''));
     return $this;
 }
Пример #7
0
 function __construct($controller, $name, $use_actions = true)
 {
     $fields = new FieldList();
     //main info
     $fields->push(new TextField('title', 'Title'));
     $fields->push(new TextField('url', 'Url'));
     $categoryField = new TextField('event_category', 'Category');
     $categoryField->setAttribute('class', 'event-category-autocomplete text');
     $fields->push($categoryField);
     //location
     $fields->push(new TextField('location', 'Location'));
     //duration
     $fields->push($start_date = new TextField('start_date', 'Start Date'));
     $fields->push($end_date = new TextField('end_date', 'End Date'));
     $start_date->addExtraClass('date');
     $end_date->addExtraClass('date');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveEvent', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'location'), new RequiredFields('start_date', 'end_date')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * returns the form
  * @return Form
  */
 public function getGoogleSiteSearchForm($name = "GoogleSiteSearchForm")
 {
     $formIDinHTML = "Form_" . $name;
     if ($page = GoogleCustomSearchPage::get()->first()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript('googlecustomsearch/javascript/GoogleCustomSearch.js');
         $apiKey = Config::inst()->get("GoogleCustomSearchExt", "api_key");
         $cxKey = Config::inst()->get("GoogleCustomSearchExt", "cx_key");
         if ($apiKey && $cxKey) {
             Requirements::customScript("\n\t\t\t\t\t\tGoogleCustomSearch.apiKey = '" . $apiKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.cxKey = '" . $cxKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.formSelector = '#" . $formIDinHTML . "';\n\t\t\t\t\t\tGoogleCustomSearch.inputFieldSelector = '#" . $formIDinHTML . "_search';\n\t\t\t\t\t\tGoogleCustomSearch.resultsSelector = '#" . $formIDinHTML . "_Results';\n\t\t\t\t\t", "GoogleCustomSearchExt");
             $form = new Form($this->owner, 'GoogleSiteSearchForm', new FieldList($searchField = new TextField('search'), $resultField = new LiteralField($name . "_Results", "<div id=\"" . $formIDinHTML . "_Results\"></div>")), new FieldList(new FormAction('doSearch', _t("GoogleCustomSearchExt.GO", "Full Results"))));
             $form->setFormMethod('GET');
             if ($page = GoogleCustomSearchPage::get()->first()) {
                 $form->setFormAction($page->Link());
             }
             $form->disableSecurityToken();
             $form->loadDataFrom($_GET);
             $searchField->setAttribute("autocomplete", "off");
             $form->setAttribute("autocomplete", "off");
             return $form;
         } else {
             user_error("You must set an API Key and a CX key in your configs to use the Google Custom Search Form", E_USER_NOTICE);
         }
     } else {
         user_error("You must create a GoogleCustomSearchPage first.", E_USER_NOTICE);
     }
 }
 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $input = new TextField('Days', 'Past Number of Days');
     $input->setAttribute('Placeholder', 'Days');
     $fields->push($input);
     return $fields;
 }
 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $input = new TextField('SearchTerm', 'Search');
     $input->setAttribute('Placeholder', 'Search Term');
     $fields->push($input);
     return $fields;
 }
Пример #11
0
 public function SpeakerSearchForm()
 {
     $searchField = new TextField('mq', 'Search Speaker', $this->getSearchQuery());
     $searchField->setAttribute("placeholder", "first name, last name or irc nickname");
     $fields = new FieldList($searchField);
     $form = new SearchForm($this, 'SpeakerSearchForm', $fields);
     $form->setFormAction($this->Link('results'));
     return $form;
 }
 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $input = new TextField('PageName', 'Page');
     $input->setAttribute('Placeholder', 'Page Name');
     $fields->push($input);
     $static = new CheckboxField('DisplayLinks', 'Display Selected Links?');
     $fields->push($static);
     return $fields;
 }
    /**
     * 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
     *                                     {@link FormAction} objects
     * @param bool $checkCurrentUser If set to TRUE, it will be checked if a
     *                               the user is currently logged in, and if
     *                               so, only a logout button will be rendered
     * @param string $authenticatorClassName Name of the authenticator class that this form uses.
     */
    public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
    {
        // This is now set on the class directly to make it easier to create subclasses
        // $this->authenticator_class = $authenticatorClassName;
        $customCSS = project() . '/css/member_login.css';
        if (Director::fileExists($customCSS)) {
            Requirements::css($customCSS);
        }
        if (isset($_REQUEST['BackURL'])) {
            $backURL = $_REQUEST['BackURL'];
        } else {
            $backURL = Session::get('BackURL');
        }
        if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
            $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
            $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
        } else {
            if (!$fields) {
                $label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
                $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), $emailField = new TextField("Email", $label, null, null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password')));
                if (Security::config()->remember_username) {
                    $emailField->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');
                    $emailField->setAttribute('autocomplete', 'off');
                }
                if (Security::config()->autologin_enabled) {
                    $fields->push(CheckboxField::create("Remember", _t('Member.KEEPMESIGNEDIN', "Keep me signed in"))->setAttribute('title', sprintf(_t('Member.REMEMBERME', "Remember me next time? (for %d days on this device)"), Config::inst()->get('RememberLoginHash', 'token_expiry_days'))));
                }
            }
            if (!$actions) {
                $actions = new FieldList(new FormAction('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>'));
            }
        }
        if (isset($backURL)) {
            $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
        }
        // Reduce attack surface by enforcing POST requests
        $this->setFormMethod('POST', true);
        parent::__construct($controller, $name, $fields, $actions);
        $this->setValidator(new RequiredFields('Email', 'Password'));
        // Focus on the email input when the page is loaded
        $js = <<<JS
\t\t\t(function() {
\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_Email");
\t\t\t\tif(el && el.focus && (typeof jQuery == 'undefined' || jQuery(el).is(':visible'))) el.focus();
\t\t\t})();
JS;
        Requirements::customScript($js, 'MemberLoginFormFieldFocus');
    }
 /**
  * Add URL field and a read-only External ID field to CMS form.
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $descriptionFieldName = $this->getModelFieldName(self::DescriptionFieldName);
     $fields->insertBefore(new TextField($this->linkFieldName(), 'Feed URL'), $descriptionFieldName);
     $fields->insertAfter(new DropdownField(self::FeedTypeFieldName, 'Type', static::feed_types()), $descriptionFieldName);
     $fields->insertAfter($field = new TextField(self::XPathFieldName, 'XPath'), $descriptionFieldName);
     $field->setAttribute('placeholder', $this->defaultXPath());
     $fields->insertAfter(new CheckboxField(self::ValidateFeedFieldName, 'Validate feed', true), $descriptionFieldName);
     if ($idFieldName = $this->externalIDFieldName()) {
         if ($externalID = $this->owner->{$idFieldName}) {
             $fields->push(new LiteralField($externalID, 'Feed ID', "<p>{$externalID}</p>"));
         }
     }
 }
Пример #15
0
 public function __construct($arg1 = null, $arg2 = null)
 {
     if ($arg1 === null) {
         $arg1 = new TextField('StreetName', '');
         $arg1->setAttribute('placeholder', _t('GeoMemberExtension.STREETNAME'));
         $arg1->setAttribute('style', 'width:300px');
     }
     if ($arg2 === null) {
         $arg2 = new TextField('StreetNumber', '');
         $arg2->setAttribute('placeholder', _t('GeoMemberExtension.STREETNUMBER'));
         $arg2->setAttribute('style', 'width:75px');
     }
     $this->streetNameField = $arg1;
     $this->streetNumberField = $arg2;
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang == 'fr') {
         parent::__construct($arg2, $arg1);
     } else {
         parent::__construct($arg1, $arg2);
     }
     $this->setTitle(_t('GeoMemberExtension.ADDRESSHEADER', 'Address'));
     $this->setFieldHolderTemplate('AddressFieldHolder');
 }
Пример #16
0
 public function SearchForm()
 {
     $searchText = '';
     if ($this->request && $this->request->getVar('Search')) {
         $searchText = $this->request->getVar('Search');
     }
     $queryField = new TextField('Search', FALSE, $searchText);
     $queryField->setAttribute('placeholder', 'Search news');
     $fields = new FieldList($queryField);
     $actions = new FieldList(new FormAction('results', 'Search'));
     $form = new Form($this, 'SearchForm', $fields, $actions);
     $form->setFormMethod('get');
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * @param ISurveyStep $current_step
  * @param ISurveyQuestionTemplate $question
  * @param ISurveyAnswer $answer
  * @return FormField
  */
 public function build(ISurveyStep $current_step, ISurveyQuestionTemplate $question, ISurveyAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $this->buildDependantRules($current_step, $question, $field);
     return $field;
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     if ($rsvp) {
         $field->setValue($rsvp->findAnswerByQuestion($question)->Value);
     } else {
         $field->setValue($question->initialValue());
     }
     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);
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('Theme');
     $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemesExtended());
     $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
     $fields->addFieldToTab('Root.Theme', $themeDropdownField);
     // Colors
     $fields->addFieldToTab('Root.Theme', new HeaderField('ColorH', _t('ThemeSiteConfigExtension.ColorH', 'Colors')));
     $fields->addFieldToTab('Root.Theme', new MiniColorsField('BaseColor', _t('ThemeSiteConfigExtension.BaseColor', 'Base Color')));
     $fields->addFieldToTab('Root.Theme', new MiniColorsField('PrimaryColor', _t('ThemeSiteConfigExtension.PrimaryColor', 'Primary Color')));
     $fields->addFieldToTab('Root.Theme', new MiniColorsField('SecondaryColor', _t('ThemeSiteConfigExtension.SecondaryColor', 'Secondary Color')));
     // Fonts
     $fields->addFieldToTab('Root.Theme', new HeaderField('FontsH', _t('ThemeSiteConfigExtension.FontsH', 'Fonts')));
     $fields->addFieldToTab('Root.Theme', $hf = new TextField('HeaderFont', _t('ThemeSiteConfigExtension.HeaderFont', 'Header Font')));
     $fields->addFieldToTab('Root.Theme', $bf = new TextField('BodyFont', _t('ThemeSiteConfigExtension.BodyFont', 'Body Font')));
     $fields->addFieldToTab('Root.Theme', $gf = new TextField('GoogleFonts', _t('ThemeSiteConfigExtension.GoogleFonts', 'Google Fonts')));
     $hf->setAttribute('placeholder', 'Arial, Helvetica, sans-serif');
     $bf->setAttribute('placeholder', 'Arial, Helvetica, sans-serif');
     $gf->setAttribute('placeholder', 'family=Open+Sans:400italic,400,600&subset=latin,latin-ext');
     // Images
     $fields->addFieldToTab('Root.Theme', new HeaderField('ImagesH', _t('ThemeSiteConfigExtension.ImagesH', 'Images')));
     $fields->addFieldToTab('Root.Theme', ImageUploadField::createForClass($this, 'Logo', _t('ThemeSiteConfigExtension.Logo', 'Logo')));
     $fields->addFieldToTab('Root.Theme', $icon = ImageUploadField::createForClass($this, 'Icon', _t('ThemeSiteConfigExtension.Icon', 'Icon')));
     if (is_file(Director::baseFolder() . $this->FaviconPath())) {
         $icon->setDescription(_t('ThemeSiteConfigExtension.FaviconPreview', 'Favicon preview') . ' <img src="' . $this->FaviconPath() . '" alt="Favicon" />');
     } else {
         $icon->setDescription(_t('ThemeSiteConfigExtension.NoFavicon', 'No favicon created for this site'));
     }
     $fields->addFieldToTab('Root.Theme', ImageUploadField::createForClass($this, 'BackgroundImages', _t('ThemeSiteConfigExtension.BackgroundImages', 'Background Images')));
     $fields->addFieldToTab('Root.Theme', new DropdownField('BackgroundRepeat', _t('ThemeSiteConfigExtension.BackgroundRepeat', 'Background Repeat'), array(self::BACKGROUND_NO_REPEAT => 'no repeat', self::BACKGROUND_REPEAT => 'repeat', self::BACKGROUND_REPEAT_X => 'repeat x', self::BACKGROUND_REPEAT_Y => 'repeat y')));
     if (Director::isDev() || Permission::check('ADMIN')) {
         $fields->addFieldToTab('Root.Theme', new HeaderField('ThemeDevHeader', 'Dev tools'));
         $fields->addFieldToTab('Root.Theme', new CheckboxField('RefreshTheme'));
         $fields->addFieldToTab('Root.Theme', new CheckboxField('RefreshIcon'));
     }
     // Simple Google Analytics helper, disable if other extension are found
     if (!$this->owner->hasExtension('GoogleConfig') && !$this->owner->hasExtension('ZenGoogleAnalytics')) {
         $fields->addFieldToTab('Root.Main', $ga = new TextField('GoogleAnalyticsCode'));
         $ga->setAttribute('placeholder', 'UA-0000000-00');
     }
     return $fields;
 }
Пример #20
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;
 }
 /**
  * @param ITrackQuestionTemplate $question
  * @param ITrackAnswer $answer
  * @return FormField
  */
 public function build(ITrackQuestionTemplate $question, ITrackAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     $field->setFieldHolderTemplate('BootstrapFieldHolder');
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     } else {
         $field->setValue($question->initialValue());
     }
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     return $field;
 }
Пример #22
0
 public function SubscribeNewsletterForm()
 {
     $oFields = new FieldList(new HeaderField('header', $this->Header), new LiteralField('intro', $this->Body), new HiddenField('MailChimpListID', false, $this->MailChimpListID));
     // get field settings from config file
     $aFieldSettings = Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_Storage_Fields);
     $sLabelLocation = Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_FieldLabel_Location);
     $aRequiredFields = array();
     foreach ($aFieldSettings as $key => $value) {
         // key is formulier, value is mailchimp of data object
         $sTitle = '';
         $sPlaceholder = '';
         if ($key == 'Email') {
             if ($sLabelLocation == NewsLetterWidget_FieldLabel_Location_Placeholder) {
                 $sPlaceholder = $this->FieldLabelEmail;
             } else {
                 $sTitle = $this->FieldLabelEmail;
             }
             $field = new EmailField("Email", $sTitle);
         } else {
             if ($key == 'Name') {
                 if ($sLabelLocation == NewsLetterWidget_FieldLabel_Location_Placeholder) {
                     $sPlaceholder = $this->FieldLabelName;
                 } else {
                     $sTitle = $this->FieldLabelName;
                 }
                 $field = new TextField('Name', $sTitle);
             } else {
                 if ($sLabelLocation == NewsLetterWidget_FieldLabel_Location_Placeholder) {
                     $sPlaceholder = $key;
                 } else {
                     $sTitle = $key;
                 }
                 $field = new TextField($key, $sTitle);
             }
         }
         if ($sLabelLocation == NewsLetterWidget_FieldLabel_Location_Placeholder) {
             $field->setAttribute('placeholder', $sPlaceholder);
         }
         array_push($aRequiredFields, $key);
         // voor nu is alles required
         $oFields->push($field);
     }
     foreach ($aRequiredFields as $oReqField) {
         $oFields->fieldByName($oReqField)->addExtraClass('required');
     }
     $oActions = new FieldList(new FormAction("subscribeNewsLetter", $this->BtnLabel));
     $oForm = new Form($this, "SubscribeNewsletterForm", $oFields, $oActions);
     $oForm->addExtraClass('ajaxForm');
     $oForm->addExtraClass('widgetNewsLetter');
     $oForm->addExtraClass('box');
     $oForm->forAjaxTemplate();
     return $oForm;
 }
Пример #23
0
 /**
  * @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;
 }
 /**
  * Provide content for the Preview tab
  * 
  * @return \Tab
  */
 protected function previewTab()
 {
     $tab = new Tab('Preview');
     // Preview iframe
     $previewLink = '/admin/emails/EmailTemplate/PreviewEmail/?id=' . $this->ID;
     $iframe = new LiteralField('iframe', '<iframe src="' . $previewLink . '" style="width:800px;background:#fff;min-height:500px;vertical-align:top"></iframe>');
     $tab->push($iframe);
     if (class_exists('CmsInlineFormAction')) {
         // Test emails
         $compo = new FieldGroup($recipient = new TextField('SendTestEmail', ''), $action = new CmsInlineFormAction('doSendTestEmail', 'Send'));
         $recipient->setAttribute('placeholder', '*****@*****.**');
         $recipient->setValue(Email::config()->admin_email);
         $tab->push(new HiddenField('EmailTemplateID', '', $this->ID));
         $tab->push(new HeaderField('SendTestEmailHeader', 'Send test email'));
         $tab->push($compo);
     }
     return $tab;
 }
 public function getHTMLFragments($gridField)
 {
     if (!$this->checkDataType($gridField->getList())) {
         return;
     }
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $columns = $gridField->getColumns();
     $filterArguments = $gridField->State->GridFieldFilterHeader->Columns->toArray();
     $currentColumn = 0;
     foreach ($columns as $columnField) {
         $currentColumn++;
         $metadata = $gridField->getColumnMetadata($columnField);
         $title = $metadata['title'];
         $fields = new FieldGroup();
         if ($title && $gridField->getList()->canFilterBy($columnField)) {
             $value = '';
             if (isset($filterArguments[$columnField])) {
                 $value = $filterArguments[$columnField];
             }
             $field = new TextField('filter[' . $gridField->getName() . '][' . $columnField . ']', '', $value);
             $field->addExtraClass('ss-gridfield-sort');
             $field->addExtraClass('no-change-track');
             $field->setAttribute('placeholder', _t('GridField.FilterBy', "Filter by ") . _t('GridField.' . $metadata['title'], $metadata['title']));
             $fields->push($field);
             $fields->push(GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-reset')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField));
         }
         if ($currentColumn == count($columns)) {
             $fields->push(GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->addExtraClass('ss-gridfield-button-filter')->setAttribute('title', _t('GridField.Filter', "Filter"))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField));
             $fields->push(GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-close')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField));
             $fields->addExtraClass('filter-buttons');
             $fields->addExtraClass('no-change-track');
         }
         $forTemplate->Fields->push($fields);
     }
     return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'));
 }
 /**
  *
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"));
     $searchField->setAttribute('data-search-url', Controller::join_links($gridField->Link('search')));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation(null))) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
 public function SearchForm()
 {
     $fields = new FieldList();
     $fields->push(new DateField('DateFrom', _t('Mandrill.DATEFROM', 'From'), $this->getParam('DateFrom', date('Y-m-d', strtotime('-30 days')))));
     $fields->push(new DateField('DateTo', _t('Mandrill.DATETO', 'To'), $this->getParam('DateTo', date('Y-m-d'))));
     $fields->push($queryField = new TextField('Query', _t('Mandrill.QUERY', 'Query'), $this->getParam('Query')));
     $queryField->setAttribute('placeholder', 'full_email:joe@domain.* AND sender:me@company.com OR subject:welcome');
     $queryField->setDescription(_t('Mandrill.QUERYDESC', 'For more information about query syntax, please visit <a target="_blank" href="http://help.mandrill.com/entries/22211902">Mandrill Support</a>'));
     $fields->push(new DropdownField('Limit', _t('Mandrill.LIMIT', 'Limit'), array(10 => 10, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000), $this->getParam('Limit', 100)));
     $actions = new FieldList();
     $actions->push(new FormAction('doSearch', _t('Mandrill.DOSEARCH', 'Search')));
     $form = new Form($this, 'SearchForm', $fields, $actions);
     return $form;
 }
Пример #28
0
 /**
  * @return \FieldList
  */
 public function getGeoFields()
 {
     $fields = new FieldList();
     $fields->push(new HeaderField('AddressHeader', _t('GeoMemberExtension.ADDRESSHEADER', 'Address')));
     $fields->push($this->getAddressFields(), 'Address');
     $fields->push(new HeaderField('GeoHeader', _t('GeoMemberExtension.GEOHEADER', 'Geo data')));
     $latitude = new TextField('Latitude', _t('GeoMemberExtension.LATITUDE', 'Latitude'), $this->owner->Latitude ? $this->owner->Latitude : null);
     $latitude->setAttribute('placeholder', _t('GeoMemberExtension.LATITUDE', 'Latitude'));
     $latitude->setTitle('');
     $longitude = new TextField('Longitude', _t('GeoMemberExtension.LONGITUDE', 'Longitude'), $this->owner->Longitude ? $this->owner->Longitude : null);
     $longitude->setAttribute('placeholder', _t('GeoMemberExtension.LONGITUDE', 'Longitude'));
     $longitude->setTitle('');
     $coords = new FieldGroup($latitude, $longitude);
     $coords->setFieldHolderTemplate('AddressFieldHolder');
     $coords->setTitle(_t('GeoMemberExtension.COORDS', 'Coordinates'));
     $fields->push($coords);
     $fields->push(new CheckboxField('GeolocateOnLocation', _t('GeoMemberExtension.GEOLOCATEONLOCATION', 'Only show location instead of full address')));
     $tz = timezone_identifiers_list();
     $timezone = $this->owner->Timezone;
     if (!$timezone) {
         $timezone = date_default_timezone_get();
     }
     $fields->push($tzdd = new DropdownField('Timezone', _t('GeoMemberExtension.TIMEZONE', 'Timezone'), array_combine($tz, $tz), $timezone));
     $tzdd->setEmptyString('');
     return $fields;
 }
 public function SearchForm()
 {
     $searchText = $this->GetSearchTerm() ?: "";
     $queryType = $this->GetSearchType() ?: "";
     $category = $this->GetCategory() ?: "";
     $searchField = new TextField('Search', "Search youtube for:", $searchText);
     $searchField->setAttribute('placeholder', "Type here");
     $fields = new FieldList(new DropdownField('queryType', "Search type:", array('relevance' => 'All Videos', 'viewcount' => 'Most Viewed Videos', 'date' => 'Most recent', 'rating' => 'Top rated'), $queryType), new DropdownField('category', "Category:", $this->GetCategories(), $category), $searchField);
     $action = new FormAction('YouTubeSearchResults', _t('SearchForm.GO', 'Go'));
     $action->addExtraClass('btn btn-default btn-search');
     $action->useButtonTag = true;
     $action->setButtonContent('<i class="fa fa-search"></i><span class="text-hide">Search</span>');
     $actions = new FieldList($action);
     $form = new Form($this, 'YouTubeSearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction($this->Link() . "");
     $form->disableSecurityToken();
     return $form;
 }
Пример #30
-1
 public function getHTMLFragments($gridField)
 {
     $fields = new ArrayList();
     $state = $gridField->State->UserFormsGridField;
     $selectedField = $state->filter;
     $selectedValue = $state->value;
     // show dropdown of all the fields available from the submitted form fields
     // that have been saved. Takes the titles from the currently live form.
     $columnField = new DropdownField('FieldNameFilter', '');
     $columnField->setSource($this->columns);
     $columnField->setEmptyString(_t('UserFormsGridFieldFilterHeader.FILTERSUBMISSIONS', 'Filter Submissions..'));
     $columnField->setHasEmptyDefault(true);
     $columnField->setValue($selectedField);
     $valueField = new TextField('FieldValue', '', $selectedValue);
     $columnField->addExtraClass('ss-gridfield-sort');
     $columnField->addExtraClass('no-change-track');
     $valueField->addExtraClass('ss-gridfield-sort');
     $valueField->addExtraClass('no-change-track');
     $valueField->setAttribute('placeholder', _t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..'));
     $fields->push(new FieldGroup(new CompositeField($columnField, $valueField)));
     $fields->push(new FieldGroup(new CompositeField($start = new DateField('StartFilter', 'From'), $end = new DateField('EndFilter', 'Till'))));
     foreach (array($start, $end) as $date) {
         $date->setConfig('showcalendar', true);
         $date->setConfig('dateformat', 'y-mm-dd');
         $date->setConfig('datavalueformat', 'y-mm-dd');
         $date->addExtraClass('no-change-track');
     }
     $end->setValue($state->end);
     $start->setValue($state->start);
     $fields->push($actions = new FieldGroup(GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->addExtraClass('ss-gridfield-button-filter')->setAttribute('title', _t('GridField.Filter', "Filter"))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField), GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-close')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)));
     $actions->addExtraClass('filter-buttons');
     $actions->addExtraClass('no-change-track');
     $forTemplate = new ArrayData(array('Fields' => $fields));
     return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'));
 }