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


PHP DropdownField::setValue方法代码示例

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


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

示例1: testReadonlyField

	function testReadonlyField() {
		$dropdownField = new DropdownField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)');
		$dropdownField->setValue(1);
		$readonlyDropdownField = $dropdownField->performReadonlyTransformation();
		preg_match('/Yes/', $dropdownField->Field(), $matches);
		$this->assertEquals($matches[0], 'Yes');
	}
开发者ID:redema,项目名称:sapphire,代码行数:7,代码来源:DropdownFieldTest.php

示例2: getCMSFields

 function getCMSFields()
 {
     $fields = new FieldList();
     $fields->add(new TextField('Name', 'Name'));
     $fields->add(new HtmlEditorField('Description', 'Description'));
     $fields->add(new DropdownField('Status', 'Status', $this->dbObject('Status')->enumValues()));
     $fields->add($ddl_program = new CheckboxsetField('Program', 'Program', InteropProgramType::get()->filter('HasCapabilities', true)->sort('Order')->map("ID", "ShortName")));
     $fields->add($ddl_version = new CheckboxsetField('Version', 'Version', InteropProgramVersion::get()->map("ID", "Name")));
     $fields->add($ddl_type = new DropdownField('TypeID', 'Type', Dataobject::get("InteropCapabilityType")->map("ID", "Name", "Please Select")));
     if ($this->ID > 0) {
         $ddl_program->setValue('ID', $this->Program());
         $ddl_version->setValue('ID', $this->Version());
         $ddl_type->setValue($this->TypeID);
     }
     return $fields;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:16,代码来源:InteropCapability.php

示例3: __construct

 public function __construct(ISingleValueTemplateQuestion $question, $value = null)
 {
     $children = new FieldList();
     $this->question = $question;
     $current_user = Member::currentUser();
     $current_affiliations = $current_user->getCurrentAffiliations();
     if (!$current_affiliations) {
         $children->add($txt = new TextField($question->name(), $question->label()));
         $txt->addExtraClass('input-organization-name');
     } else {
         if (intval($current_affiliations->count()) > 1) {
             $source = array();
             foreach ($current_affiliations as $a) {
                 $org = $a->Organization();
                 $source[$org->ID] = $org->Name;
             }
             $source['0'] = "-- New One --";
             $children->add($ddl = new DropdownField($question->name() . 'ID', $question->label(), $source));
             $ddl->setEmptyString('-- Select Your Organization --');
             $ddl->addExtraClass('select-organization-name');
             if (!is_null($value)) {
                 $org = Org::get()->filter('Name', $value)->first();
                 if ($org) {
                     $ddl->setValue($org->ID);
                 }
             }
             $children->add($txt = new TextField($question->name(), ''));
             $txt->addExtraClass('input-organization-name');
         } else {
             $children->add($txt = new TextField($question->name(), $question->label(), $current_user->getOrgName()));
             $txt->addExtraClass('input-organization-name');
         }
     }
     parent::__construct($children);
     $control_css_class = strtolower($this->question->name() . '-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('survey_builder/js/survey.organization.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').survey_organization_field();\n        });");
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:39,代码来源:SurveyOrganizationField.php

示例4: __construct

 public function __construct($name, $title, $value = null)
 {
     $this->name = $name;
     $this->title = $title;
     $children = new FieldList();
     $source = Company::get()->sort('Name')->map('ID', 'Name')->toArray();
     $source['0'] = "-- New Company --";
     $children->add($ddl = new DropdownField($name . '_id', $title, $source));
     $ddl->setEmptyString('-- Select Your Company --');
     $ddl->addExtraClass('select-company-name');
     if (!is_null($value)) {
         $c = Company::get()->filter('Name', $value)->first();
         if ($c) {
             $ddl->setValue($c->ID);
         }
     }
     $children->add($txt = new TextField($name, ''));
     $txt->addExtraClass('input-company-name');
     parent::__construct($children);
     $control_css_class = strtolower('company-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('openstack/code/utils/CustomHTMLFields/js/company.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').company_field();\n        });");
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:24,代码来源:CompanyField.php

示例5: TextField

 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('LastName', "Last Name");
     $TitleField = new TextField('Title', "Title");
     $BioField = new TinyMCEEditorField('Bio', "Bio");
     $BioField->addExtraClass('bio');
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country of Residence', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $WillingVideoField = new CheckboxField('WillingToPresentVideo', "Willing to present via video conference.");
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Willing to travel
     $WillingToTravel = new OptionSetField('WillingToTravel', 'I am willing to travel to events:', array(1 => 'Yes', 0 => 'No'));
     // Countries to travel
     $CountriesToTravelField = new MultiDropdownField('CountriesToTravel', 'Countries willing to travel to:', $CountryCodes);
     $CountriesToTravelField->addExtraClass('travel-field');
     // Spoken Languages
     $LanguageField1 = new TextField('Language[1]', '#1');
     $LanguageField2 = new TextField('Language[2]', '#2');
     $LanguageField3 = new TextField('Language[3]', '#3');
     $LanguageField4 = new TextField('Language[4]', '#4');
     $LanguageField5 = new TextField('Language[5]', '#5');
     // Area of Expertise
     $ExpertiseField1 = new TextField('Expertise[1]', '#1');
     $ExpertiseField2 = new TextField('Expertise[2]', '#2');
     $ExpertiseField3 = new TextField('Expertise[3]', '#3');
     $ExpertiseField4 = new TextField('Expertise[4]', '#4');
     $ExpertiseField5 = new TextField('Expertise[5]', '#5');
     // Links To Presentations
     $PresentationLinkField1 = new TextField('PresentationLink[1]', '#1');
     $PresentationTitleField1 = new TextField('PresentationTitle[1]', '');
     $PresentationLinkField2 = new TextField('PresentationLink[2]', '#2');
     $PresentationTitleField2 = new TextField('PresentationTitle[2]', '');
     $PresentationLinkField3 = new TextField('PresentationLink[3]', '#3');
     $PresentationTitleField3 = new TextField('PresentationTitle[3]', '');
     $PresentationLinkField4 = new TextField('PresentationLink[4]', '#4');
     $PresentationTitleField4 = new TextField('PresentationTitle[4]', '');
     $PresentationLinkField5 = new TextField('PresentationLink[5]', '#5');
     $PresentationTitleField5 = new TextField('PresentationTitle[5]', '');
     $NotesField = new TinyMCEEditorField('Notes', "Notes");
     $NotesField->addExtraClass('notes');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $PhotoField->setValue(null, $speaker);
         $OptInField->setValue($speaker->AvailableForBureau);
         $WillingVideoField->setValue($speaker->WillingToPresentVideo);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $WillingToTravel->setValue($speaker->WillingToTravel);
         $NotesField->setValue($speaker->Notes);
         foreach ($speaker->AreasOfExpertise() as $key => $expertise) {
             if ($key > 4) {
                 break;
             }
             ${'ExpertiseField' . ($key + 1)}->setValue($expertise->Expertise);
//.........这里部分代码省略.........
开发者ID:Thingee,项目名称:openstack-org,代码行数:101,代码来源:EditSpeakerProfileForm.php

示例6: 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

示例7: TextField

 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "Speaker's First Name");
     $LastNameField = new TextField('LastName', "Speaker's Last Name");
     $TitleField = new TextField('Title', "Speaker's Title");
     $BioField = new TextAreaField('Bio', "Speaker's Bio");
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $Divider = new LiteralField('hr', '<hr/>');
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     $ExpertiseField = new TextareaField('Expertise', 'Topics of interest (one per line)');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $OptInField->setValue($speaker->AvailableForBureau);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $ExpertiseField->setValue($speaker->Expertise);
         $PhotoField->setValue(null, $speaker);
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $Divider, $OptInField, $FundedTravelField, $CountryField, $ExpertiseField);
     $actions = new FieldList(new FormAction('addAction', 'Save Speaker Details'));
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:76,代码来源:EditSpeakerProfileForm.php

示例8: MonthJumpForm

 public function MonthJumpForm()
 {
     $this->parseURL($this->getRequest());
     $dummy = sfDate::getInstance($this->startDate);
     $range = range($dummy->subtractYear(3)->format('Y'), $dummy->addYear(6)->format('Y'));
     $year_map = array_combine($range, $range);
     $f = new Form($this, "MonthJumpForm", new FieldList($m = new DropdownField('Month', '', CalendarUtil::get_months_map('%B')), $y = new DropdownField('Year', '', $year_map)), new FieldList(new FormAction('doMonthJump', _t('Calendar.JUMP', 'Go'))));
     if ($this->startDate) {
         $m->setValue($this->startDate->format('m'));
         $y->setValue($this->startDate->format('Y'));
     } else {
         $m->setValue(date('m'));
         $y->setValue(date('Y'));
     }
     return $f;
 }
开发者ID:andrewandante,项目名称:silverstripe-event-calendar,代码行数:16,代码来源:Calendar.php

示例9: FolderDropdown

 /**
  * Returns the folder selection dropdown to the template
  *
  * @param int $id The ID of the folder that is selected
  * @return DropdownField
  */
 public function FolderDropdown($id = null)
 {
     if (!$id) {
         $id = $this->CurrentUploadFolder()->ID;
     }
     if (class_exists("SimpleTreeDropdownField")) {
         $d = new SimpleTreeDropdownField("UploadFolderID_{$this->id()}", '', "Folder", $id, "Filename");
     } else {
         $folders = DataObject::get("Folder");
         $d = new DropdownField("UploadFolderID_{$this->id()}", '', $folders->toDropDownMap("ID", "Title"), $id);
     }
     $group = new FieldGroup($d, new LiteralField("slash{$this->id()}", " / "), new TextField("NewFolder_{$this->id()}", ""), $a = new FormAction("ok_{$this->id()}", _t('Uploadify.CHANGEFOLDERACTION', 'Change')));
     $a->useButtonTag = true;
     $a->addExtraClass("{'url' : '" . $this->Link('newfolder') . "' }");
     $d->setValue($id);
     return $group;
 }
开发者ID:leeyisoft,项目名称:Uploadify,代码行数:23,代码来源:UploadifyField.php

示例10: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($value, $source = null)
 {
     if ($source instanceof DataObject) {
         $name = $this->getName();
         if ($source->hasMethod($name)) {
             $value = $source->{$name}()->getIDList();
         }
     } elseif ($value instanceof SS_List) {
         $value = $value->column('ID');
     }
     return parent::setValue(array_filter($value));
 }
开发者ID:salted-herring,项目名称:silverstripe-tagfield,代码行数:15,代码来源:TagField.php

示例11: setValue

 /**
  * Load a value into this CheckboxSetField
  */
 public function setValue($val, $obj = null)
 {
     // If we're not passed a value directly,
     // we can look for it in a relation method on the object passed as a second arg
     if (!$val && $obj && $obj instanceof DataObject && $obj->hasMethod($this->name)) {
         $funcName = $this->name;
         $val = array_values($obj->{$funcName}()->getIDList());
     }
     if ($val) {
         if (!$this->multiple && is_array($val)) {
             throw new InvalidArgumentException('No array values allowed with multiple=false');
         }
         if ($this->multiple) {
             $parts = is_array($val) ? $val : preg_split("/ *, */", trim($val));
             if (ArrayLib::is_associative($parts)) {
                 throw new InvalidArgumentException('No associative arrays allowed multiple=true');
             }
             // Doesn't check against unknown values in order to allow for less rigid data handling.
             // They're silently ignored and overwritten the next time the field is saved.
             parent::setValue($parts);
         } else {
             if (!in_array($val, array_keys($this->getSource()))) {
                 throw new InvalidArgumentException(sprintf('Invalid value "%s" for multiple=false', Convert::raw2xml($val)));
             }
             parent::setValue($val);
         }
     } else {
         parent::setValue($val);
     }
     return $this;
 }
开发者ID:normann,项目名称:sapphire,代码行数:34,代码来源:ListboxField.php

示例12: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($value, $source = null)
 {
     if (is_string($value)) {
         $value = explode(',', $value);
     }
     if ($source instanceof DataObject) {
         $name = $this->getName();
         $value = explode(',', $source->{$name});
     }
     if ($source instanceof SS_List) {
         $value = $source->column('ID');
     }
     if (is_null($value)) {
         $value = array();
     }
     return parent::setValue(array_filter($value));
 }
开发者ID:mediabeastnz,项目名称:silverstripe-tagfield,代码行数:20,代码来源:StringTagField.php

示例13: augmentMailChimpField

 protected function augmentMailChimpField(FormField $field, string $component, FlexiFormMailChimpClient $client)
 {
     switch ($component) {
         case 'MailChimpSendWelcome':
             $field->setTitle('Send Welcome Email');
             $field->description = 'flag to control whether the Welcome Email is sent. Has no effect if double opt-in is enabled.';
             break;
         case 'MailChimpDoubleOptIn':
             $field->setTitle('Require Double Opt-In');
             $field->description = 'flag to control whether a double opt-in confirmation message is sent, defaults to true. Abusing this may cause your account to be suspended.';
             break;
         case 'MailChimpEmailField':
             $field->setTitle('Subscription Field');
             $field->description = 'Used as the subscriber email. Must be an Email Field or subclass.';
             break;
         case 'MailChimpEmailType':
             // @TODO ought to let user select preference through a form field [ similar to interest groups? ]
             $field->setTitle('Email Preference');
             $field->description = 'email type preference for subscribers (html or text - defaults to html)';
             break;
         case 'MailChimpApiKey':
             if ($client->isApiKeyValid()) {
                 $field->description = 'This API Key is Valid.';
             } else {
                 if ($client->getApiKey() == '') {
                     $field->description = 'Your MailChimp API Key. Found under Account Extras > Your API Keys';
                 } else {
                     $field->description = 'This API Key is not Valid.';
                 }
             }
             $field->setTitle('MailChimp API Key');
             break;
         case 'MailChimpListID':
             if ($lists = $client->getLists(array('limit' => 100, 'sort_field' => 'web'))) {
                 $value = $field->Value();
                 $source = array('' => 'Please Select a List');
                 $field = new DropdownField($field->getName());
                 $field->description = 'Subscribers will be added to this list. Lists are refreshed every 10 minutes.';
                 if ($lists['total'] > 0) {
                     foreach ($lists['data'] as $list) {
                         $source[$list['id']] = $list['name'];
                     }
                 }
                 $field->setValue($value);
                 $field->setSource($source);
             } else {
                 $field = $field->performReadonlyTransformation();
                 if (!$client->isApiKeyValid()) {
                     $field->setValue('Invalid API Key');
                 } else {
                     $field->setValue('Error loading Lists from your Account');
                 }
             }
             $field->setTitle('MailChimp List ID');
             break;
     }
     return $field;
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-mailchimp-flexiform,代码行数:58,代码来源:FlexiFormMailChimpHandler.php

示例14: addShippingAddressFields

 /**
  * Add fields for shipping address and required fields to the validator.
  * 
  * @param Array $fields Array of fields
  * @param OrderFormValidator $validator Checkout form validator
  */
 private function addShippingAddressFields(&$fields, &$validator)
 {
     $firstNameField = new TextField('Shipping[FirstName]', _t('CheckoutPage.FIRSTNAME', "First Name"));
     $firstNameField->addExtraClass('shipping-firstname');
     $firstNameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_FIRSTNAME', "Please enter a first name."));
     $surnameField = new TextField('Shipping[Surname]', _t('CheckoutPage.SURNAME', "Surname"));
     $surnameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_SURNAME', "Please enter a surname."));
     $addressField = new TextField('Shipping[Address]', _t('CheckoutPage.ADDRESS1', "Address 1"));
     $addressField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_ADDRESS', "Please enter an address."));
     $cityField = new TextField('Shipping[City]', _t('CheckoutPage.CITY', "City"));
     $cityField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_CITY', "Please enter a city."));
     $countryField = new DropdownField('Shipping[Country]', _t('CheckoutPage.COUNTRY', "Country"), Country::shipping_countries());
     $countryField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_COUNTRY', "Please enter a country."));
     if (!Member::currentUserID() && Geoip::$default_country_code) {
         $countryField->setValue(Geoip::$default_country_code);
     }
     $regions = Region::shipping_regions();
     $regionField = null;
     if (!empty($regions)) {
         $regionField = new RegionField('Shipping[Region]', _t('CheckoutPage.REGION', "Region"));
         $regionField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_REGION', "Please enter a country."));
     }
     $sameAddressField = new CheckboxField('ShipToBillingAddress', _t('CheckoutPage.SAME_ADDRESS', "to same address?"));
     $sameAddressField->addExtraClass('shipping-same-address');
     $shippingAddressFields = new CompositeField(new HeaderField(_t('CheckoutPage.SHIPPING_ADDRESS', "Shipping Address"), 3), $sameAddressField, $firstNameField, $surnameField, new TextField('Shipping[Company]', _t('CheckoutPage.COMPANY', "Company")), $addressField, new TextField('Shipping[AddressLine2]', _t('CheckoutPage.ADDRESS2', "Address 2")), $cityField, new TextField('Shipping[PostalCode]', _t('CheckoutPage.POSTAL_CODE', "Postal Code")), new TextField('Shipping[State]', _t('CheckoutPage.STATE', "State")), $countryField);
     if ($regionField) {
         $shippingAddressFields->push($regionField);
     }
     $shippingAddressFields->setID('ShippingAddress');
     $fields['ShippingAddress'][] = $shippingAddressFields;
     $validator->addRequiredField('Shipping[FirstName]');
     $validator->addRequiredField('Shipping[Surname]');
     $validator->addRequiredField('Shipping[Address]');
     $validator->addRequiredField('Shipping[City]');
     $validator->addRequiredField('Shipping[Country]');
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:42,代码来源:CheckoutPage.php

示例15: presetDropdownWithDefault

 /**
  * Presets the given dropdown field with the default tax rate
  * 
  * @param DropdownField $dropdownField Dropdown field to manipulate
  * @param DataObject    $object        Tax rate related object
  * @param string        $relationName  Tax rate relation name
  * 
  * @return SilvercartTax
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 26.10.2012
  */
 public static function presetDropdownWithDefault($dropdownField, $object, $relationName = 'SilvercartTax')
 {
     $relationIDName = $relationName . 'ID';
     $dropdownField->setEmptyString('');
     $dropdownField->setHasEmptyDefault(false);
     if ($object->{$relationIDName} == 0) {
         $defaultTaxRate = self::getDefault();
         if ($defaultTaxRate) {
             $dropdownField->setValue($defaultTaxRate->ID);
         }
     }
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:24,代码来源:SilvercartTax.php


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