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


PHP DropdownField::setAttribute方法代码示例

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


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

示例1: getCMSFields

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

示例2: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $survey_id = isset($_REQUEST['survey_template_id']) ? intval($_REQUEST['survey_template_id']) : $this->TargetSurveyID;
     $current_template = SurveyTemplate::get()->byID($survey_id);
     $templates = SurveyTemplate::get()->exclude('ID', $survey_id);
     $allowed_templates = array();
     foreach ($templates as $template) {
         if ($template->ClassName !== $current_template->ClassName) {
             continue;
         }
         $text = $template->Title;
         if ($template instanceof EntitySurveyTemplate) {
             $text = $template->Parent()->Title . ' - ' . $text;
         }
         $allowed_templates[$template->ID] = $text;
     }
     $fields->addFieldToTab('Root.Main', $ddl_template = new DropdownField('OriginSurveyID', 'Origin Survey', $allowed_templates));
     $ddl_template->setEmptyString('-- select a survey template --');
     $fields->addFieldToTab('Root.Main', $ddl_fields = new DropdownField('OriginFieldID', 'Origin Field'));
     if (intval($this->OriginFieldID) > 0) {
         $ddl_fields->setAttribute('data-value', $this->OriginFieldID);
     }
     return $fields;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:25,代码来源:NewDataModelSurveyMigrationMapping.php

示例3: makePackageSelectorField

 /**
  * Returns a drop-down field configured from an api.listPackages call.
  *
  * NB commented code is for if they (checkfront) get events and items returning at same
  * time for packages via API at the moment can be one or the other depedning on the package
  * 'parent' or 'group' type.
  *
  * @param CheckfrontAPIPackagesResponse $apiResponse
  * @param SS_HTTPRequest $request
  * @param string $name
  *
  * @return DropdownField
  */
 protected function makePackageSelectorField(CheckfrontAPIPackagesResponse $apiResponse, SS_HTTPRequest $request, $name = self::PackageIDFieldName)
 {
     $options = $this->getAvailablePackagesMap($apiResponse);
     $field = new DropdownField($name, $this->getFieldLabel($name), $options, $request->postVar($name));
     //  $field->addExtraClass(self::PackageSelector);
     $field->setAttribute('placeholder', $this->getFieldLabel($name, 'FieldEmptyString'));
     $field->setEmptyString($this->getFieldLabel($name, 'FieldEmptyString'));
     return $field;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-checkfront,代码行数:22,代码来源:LinkGenerator.php

示例4: getColumnContent

 /**
  * {@inheritdoc}
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if ($columnName === 'MergeAction' && $record->{$this->childMethod}()->Count() > 0) {
         $dropdown = new DropdownField('Target', 'Target', $this->records->exclude('ID', $record->ID)->map());
         $dropdown->setAttribute('id', 'Target_' . $record->ID);
         $prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
         $action = GridFieldFormAction::create($gridField, 'MergeAction' . $record->ID, 'Move', 'merge', array('record' => $record->ID, 'target' => $prefix . '-target-record-' . $record->ID));
         $action->setExtraAttributes(array('data-target' => $prefix . '-target-record-' . $record->ID));
         return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
     }
     return null;
 }
开发者ID:sunnysideup,项目名称:silverstripe-blog,代码行数:15,代码来源:GridFieldMergeAction.php

示例5: getHTMLFragments

 public function getHTMLFragments($grid)
 {
     $classes = $this->getClasses($grid);
     if (!count($classes)) {
         return array();
     }
     GridFieldExtensions::include_requirements();
     $field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes, $this->defaultClass);
     $field->setAttribute('id', uniqid());
     if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
         $field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
     }
     $field->addExtraClass('no-change-track');
     $data = new ArrayData(array('Title' => $this->getTitle(), 'Link' => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'), 'ClassField' => $field));
     return array($this->getFragment() => $data->renderWith('GridFieldAddNewMultiClass'));
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:16,代码来源:MultiClassSelector.php

示例6: AddForm

 /**
  * Get the form used to create a new provider
  *
  * @return Form
  */
 public function AddForm()
 {
     $classes = ClassInfo::subclassesFor(self::$tree_class);
     array_shift($classes);
     foreach ($classes as $key => $class) {
         if (!singleton($class)->canCreate()) {
             unset($classes[$key]);
         }
         $classes[$key] = FormField::name_to_label($class);
     }
     $fields = new FieldList(new HiddenField("ParentID"), new HiddenField("Locale", 'Locale', i18n::get_locale()), $type = new DropdownField("ProviderType", "", $classes));
     $type->setAttribute('style', 'width:150px');
     $actions = new FieldList(FormAction::create("addprovider", _t('ExternalContent.CREATE', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $form = new Form($this, "AddForm", $fields, $actions);
     $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses());
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:nyeholt,项目名称:silverstripe-external-content,代码行数:23,代码来源:ExternalContentAdmin.php

示例7: getCreditCardFields

 /**
  * Create form fields to represent all of the properties on the {@link Omnipay\Common\CreditCard} object.
  * The form fields are split up into relevent sections to help with adding/removing fields as needed.
  *
  * @return FieldList
  */
 protected function getCreditCardFields()
 {
     $fields = new FieldList();
     $tabindex = 1;
     // Create personal detail fields
     $firstNameTextField = new TextField('FirstName', _t('OmnipayableForm.FIRSTNAME', 'First name'));
     $firstNameTextField->setAttribute('tabindex', $tabindex++);
     $lastNameTextField = new TextField('LastName', _t('OmnipayableForm.LASTNAME', 'Last name'));
     $lastNameTextField->setAttribute('tabindex', $tabindex++);
     $companyTextField = new TextField('Company', _t('OmnipayableForm.COMPANY', 'Company'));
     $companyTextField->setAttribute('tabindex', $tabindex++);
     $emailEmailField = new EmailField('Email', _t('OmnipayableForm.EMAIL', 'Email'));
     $emailEmailField->setAttribute('tabindex', $tabindex++);
     // Create personal details group
     $personalFieldGroup = new FieldGroup();
     $personalFieldGroup->setName('PersonalDetails');
     $personalFieldGroup->setTitle(_t('OmnipayableForm.PERSONALDETAILS', 'Personal Detials'));
     // Add basic fields to personal details group
     $personalFieldGroup->push($firstNameTextField);
     $personalFieldGroup->push($lastNameTextField);
     $personalFieldGroup->push($companyTextField);
     $personalFieldGroup->push($emailEmailField);
     // Add personal details group to fields
     $fields->push($personalFieldGroup);
     // Create credit card detail fields
     $numberCreditCardField = new CreditCardField('Number', _t('OmnipayableForm.NUMBER', 'Card number'));
     $numberCreditCardField->setAttribute('tabindex', $tabindex++);
     $cvvTextField = new TextField('Cvv', _t('OmnipayableForm.CVV', 'Security number'));
     $cvvTextField->setAttribute('tabindex', $tabindex += 3);
     $expiryMonthDropdownField = new DropdownField('ExpiryMonth', _t('OmnipayableForm.EXPIRYMONTH', 'Expiry month'), $this->getMonths());
     $expiryMonthDropdownField->setAttribute('tabindex', $tabindex++);
     $expiryMonthDropdownField->setHasEmptyDefault(true);
     $expiryYearDropdownField = new DropdownField('ExpiryYear', _t('OmnipayableForm.EXPIRYYEAR', 'Expiry year'), $this->getYears(20));
     $expiryYearDropdownField->setAttribute('tabindex', $tabindex++);
     $expiryYearDropdownField->setHasEmptyDefault(true);
     $startMonthDropdownField = new DropdownField('StartMonth', _t('OmnipayableForm.STARTMONTH', 'Start month'), $this->getMonths());
     $startMonthDropdownField->setAttribute('tabindex', $tabindex++);
     $startMonthDropdownField->setHasEmptyDefault(true);
     $startYearDropdownField = new DropdownField('StartYear', _t('OmnipayableForm.STARTYEAR', 'Start year'), $this->getYears(-20));
     $startYearDropdownField->setAttribute('tabindex', $tabindex++);
     $startYearDropdownField->setHasEmptyDefault(true);
     $issueNumberTextField = new TextField('IssueNumber', _t('OmnipayableForm.ISSUENUMBER', 'Issue number'));
     $issueNumberTextField->setAttribute('tabindex', $tabindex++);
     $typeDropdownField = new DropdownField('Type', _t('OmnipayableForm.TYPE', 'Card type'), $this->getCreditCardTypes());
     $typeDropdownField->setAttribute('tabindex', $tabindex++);
     $typeDropdownField->setHasEmptyDefault(true);
     $expiryDateFieldGroup = new FieldGroup();
     $expiryDateFieldGroup->push($expiryMonthDropdownField);
     $expiryDateFieldGroup->push($expiryYearDropdownField);
     $startDateFieldGroup = new FieldGroup();
     $startDateFieldGroup->push($startMonthDropdownField);
     $startDateFieldGroup->push($startYearDropdownField);
     // Create credit card details group
     $creditCardFieldGroup = new FieldGroup();
     $creditCardFieldGroup->setName('CardDetails');
     $creditCardFieldGroup->setTitle(_t('OmnipayableForm.CREDITCARDDETAILS', 'Card Detials'));
     // Add credit card fields to credit card details group
     $creditCardFieldGroup->push($numberCreditCardField);
     $creditCardFieldGroup->push($cvvTextField);
     $creditCardFieldGroup->push($expiryDateFieldGroup);
     $creditCardFieldGroup->push($startDateFieldGroup);
     $creditCardFieldGroup->push($issueNumberTextField);
     $creditCardFieldGroup->push($typeDropdownField);
     // Add credit card details group to fields
     $fields->push($creditCardFieldGroup);
     // Create billing address fields
     $billingAddress1TextField = new TextField('BillingAddress1', _t('OmnipayableForm.BILLINGADDRESS1', 'Address 1'));
     $billingAddress1TextField->setAttribute('tabindex', $tabindex++);
     $billingAddress2TextField = new TextField('BillingAddress2', _t('OmnipayableForm.BILLINGADDRESS2', 'Address 2'));
     $billingAddress2TextField->setAttribute('tabindex', $tabindex++);
     $billingCity = new TextField('BillingCity', _t('OmnipayableForm.BILLINGCITY', 'City'));
     $billingCity->setAttribute('tabindex', $tabindex++);
     $billingPostcode = new TextField('BillingPostcode', _t('OmnipayableForm.BILLINGPOSTCODE', 'Postcode'));
     $billingPostcode->setAttribute('tabindex', $tabindex++);
     $billingState = new TextField('BillingState', _t('OmnipayableForm.BILLINGSTATE', 'State'));
     $billingState->setAttribute('tabindex', $tabindex++);
     $billingCountry = new CountryDropdownField('BillingCountry', _t('OmnipayableForm.BILLINGCOUNTRY', 'Country'));
     $billingCountry->setAttribute('tabindex', $tabindex++);
     $billingPhone = new PhoneNumberField('BillingPhone', _t('OmnipayableForm.BILLINGPHONE', 'Phone'));
     $billingPhone->setAttribute('tabindex', $tabindex++);
     // Create billing details group
     $billingFieldGroup = new FieldGroup();
     $billingFieldGroup->setName('BillingAddress');
     $billingFieldGroup->setTitle(_t('OmnipayableForm.BILLING', 'Billing Address'));
     // Add billiing fields to billing group
     $billingFieldGroup->push($billingAddress1TextField);
     $billingFieldGroup->push($billingAddress2TextField);
     $billingFieldGroup->push($billingCity);
     $billingFieldGroup->push($billingPostcode);
     $billingFieldGroup->push($billingState);
     $billingFieldGroup->push($billingCountry);
     $billingFieldGroup->push($billingPhone);
     // Add billing details group to fields
     $fields->push($billingFieldGroup);
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:studiobonito-silverstripe-omnipayable,代码行数:101,代码来源:OmnipayableForm.php

示例8: ArchiveUnitDropdown

 public function ArchiveUnitDropdown()
 {
     $months = array();
     $months['1'] = _t('filterablearchive.JANUARY', 'Januari');
     $months['2'] = _t('filterablearchive.FEBRUARY', 'Februari');
     $months['3'] = _t('filterablearchive.MARCH', 'Maart');
     $months['4'] = _t('filterablearchive.APRIL', 'April');
     $months['5'] = _t('filterablearchive.MAY', 'Mei');
     $months['6'] = _t('filterablearchive.JUNE', 'Juni');
     $months['7'] = _t('filterablearchive.JULY', 'Juli');
     $months['8'] = _t('filterablearchive.AUGUST', 'Augustus');
     $months['9'] = _t('filterablearchive.SEPTEMBER', 'September');
     $months['10'] = _t('filterablearchive.OCTOBER', 'Oktober');
     $months['11'] = _t('filterablearchive.NOVEMBER', 'November');
     $months['12'] = _t('filterablearchive.DECEMBER', 'December');
     // build array with available archive 'units'
     $items = $this->owner->getItems();
     //$dateField = $this->owner->getFilterableArchiveConfigValue('managed_object_date_field');
     $dateField = Config::inst()->get($this->owner->className, 'managed_object_date_field');
     $itemArr = array();
     foreach ($items as $item) {
         if (!$item->{$dateField}) {
             continue;
         }
         $dateObj = DBField::create_field('Date', strtotime($item->{$dateField}));
         // add month if not yet in array;
         if ($this->owner->ArchiveUnit == 'day') {
             $arrkey = $dateObj->Format('Y/m/d/');
             $arrval = $dateObj->Format('d ') . $months[$dateObj->Format('n')] . $dateObj->Format(' Y');
         } elseif ($this->owner->ArchiveUnit == 'month') {
             $arrkey = $dateObj->Format('Y/m/');
             $arrval = $months[$dateObj->Format('n')] . $dateObj->Format(' Y');
         } else {
             $arrkey = $dateObj->Format('Y/');
             $arrval = $dateObj->Format('Y');
         }
         if (!array_key_exists($arrkey, $itemArr)) {
             $itemArr[$arrkey] = $arrval;
         }
     }
     $DrDown = new DropdownField('archiveunits', '', $itemArr);
     $DrDown->setEmptyString(_t('filterablearchive.FILTER', 'Filter items'));
     $DrDown->addExtraClass("dropdown form-control");
     // specific to the 'archive' action defined by FilterableArchiveHolder_ControllerExtension (if available)
     $ctrl = Controller::curr();
     $activeUnit = "";
     if ($ctrl::has_extension("FilterableArchiveHolder_ControllerExtension")) {
         if ($cYear = $ctrl->getArchiveYear()) {
             $activeUnit .= "{$cYear}/";
         }
         if ($cMonth = $ctrl->getArchiveMonth()) {
             $activeUnit .= str_pad("{$cMonth}/", 3, "0", STR_PAD_LEFT);
         }
         if ($cDay = $ctrl->getArchiveDay()) {
             $activeUnit .= str_pad("{$cDay}/", 3, "0", STR_PAD_LEFT);
         }
     }
     $DrDown->setValue($activeUnit);
     // again, tie this to the 'archive' action;
     $DrDown->setAttribute('onchange', "location = '{$this->owner->AbsoluteLink()}date/'+this.value;");
     return $DrDown;
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-filterablearchive,代码行数:62,代码来源:FilterableArchiveHolderExtension.php


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