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


PHP TextField::setAttribute方法代码示例

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


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

示例1: getHTMLFragments

 /**
  * 
  * @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));
 }
开发者ID:normann,项目名称:sapphire,代码行数:31,代码来源:GridFieldAddExistingAutocompleter.php

示例2: getPaymentFormFields

 /**
  * 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;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-payment-dps,代码行数:18,代码来源:DpsPxPost.php

示例3: updateCMSFields

 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;
 }
开发者ID:guttmann,项目名称:silverstripe-googleapi,代码行数:25,代码来源:GoogleAPISiteConfigExtension.php

示例4: EditProfileForm

 /**
  * @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;
 }
开发者ID:ormandroid,项目名称:ss_boilerplate,代码行数:38,代码来源:EditProfilePage.php

示例5: FieldList

 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);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:35,代码来源:SummitAttendeeInfoForm.php

示例6: setLat

 /**
  * @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;
 }
开发者ID:helpfulrobot,项目名称:nblum-silverstripe-geocodefield,代码行数:11,代码来源:GeoCodeField.php

示例7: FieldList

 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);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:31,代码来源:EventForm.php

示例8: getGoogleSiteSearchForm

 /**
  * 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);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-googlecustomsearch,代码行数:31,代码来源:GoogleCustomSearchExt.php

示例9: getDashletFields

 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $input = new TextField('Days', 'Past Number of Days');
     $input->setAttribute('Placeholder', 'Days');
     $fields->push($input);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-intranet-sis,代码行数:8,代码来源:InteractionDashlet.php

示例10: SpeakerSearchForm

 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;
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:9,代码来源:SpeakerListPage.php

示例11: getDashletFields

 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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-intranet-sis,代码行数:10,代码来源:ViewingDashlet.php

示例12: __construct

    /**
     * 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');
    }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:69,代码来源:MemberLoginForm.php

示例13: updateCMSFields

 /**
  * 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>"));
         }
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-feedme,代码行数:19,代码来源:FeedModel.php

示例14: __construct

 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');
 }
开发者ID:lekoala,项目名称:silverstripe-geotools,代码行数:23,代码来源:StreetField.php

示例15: SearchForm

 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;
 }
开发者ID:helpfulrobot,项目名称:plumpss-news,代码行数:15,代码来源:ArticleHolder.php


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