本文整理汇总了PHP中DropdownField::setSource方法的典型用法代码示例。如果您正苦于以下问题:PHP DropdownField::setSource方法的具体用法?PHP DropdownField::setSource怎么用?PHP DropdownField::setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DropdownField
的用法示例。
在下文中一共展示了DropdownField::setSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateFields
public function updateFields(FieldList $fields)
{
if (!$this->owner->ID) {
return $fields;
}
$tab = $fields->fieldByName('Root') ? $fields->findOrMakeTab('Root.Workflow') : $fields;
if (Permission::check('APPLY_WORKFLOW')) {
$definition = new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'));
$definitions = $this->workflowService->getDefinitions()->map()->toArray();
$definition->setSource($definitions);
$definition->setEmptyString(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
$tab->push($definition);
// Allow an optional selection of additional workflow definitions.
if ($this->owner->WorkflowDefinitionID) {
$fields->removeByName('AdditionalWorkflowDefinitions');
unset($definitions[$this->owner->WorkflowDefinitionID]);
$tab->push($additional = ListboxField::create('AdditionalWorkflowDefinitions', _t('WorkflowApplicable.ADDITIONAL_WORKFLOW_DEFINITIONS', 'Additional Workflows')));
$additional->setSource($definitions);
$additional->setMultiple(true);
}
}
// Display the effective workflow definition.
if ($effective = $this->getWorkflowInstance()) {
$title = $effective->Definition()->Title;
$tab->push(ReadonlyField::create('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $title));
}
if ($this->owner->ID) {
$config = new GridFieldConfig_Base();
$config->addComponent(new GridFieldEditButton());
$config->addComponent(new GridFieldDetailForm());
$insts = $this->owner->WorkflowInstances();
$log = new GridField('WorkflowLog', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log'), $insts, $config);
$tab->push($log);
}
}
示例2: setSource
public function setSource($source)
{
parent::setSource($source);
if (!$source instanceof SS_Map) {
throw new Exception('SS_Map');
}
$this->toggleStar();
return $this;
}
示例3: getDefaultValueFormField
public function getDefaultValueFormField($field_name = 'FieldDefaultValue')
{
$field = new DropdownField($field_name, 'Default Value', array());
if ($this->Options()->exists()) {
$field->setSource($this->Options()->map('Value', 'Label')->toArray());
}
$field->setEmptyString('None (Displays Empty String)');
$field->description = 'Optional. This value will be preselectd.';
return $field;
}
示例4: getDefaultSearchContext
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$results = $this->blockManager->getBlockClasses();
if (sizeof($results) > 1) {
$classfield = new DropdownField('ClassName', _t('Block.BlockType', 'Block Type'));
$classfield->setSource($results);
$classfield->setEmptyString(_t('Block.Any', '(any)'));
$context->addField($classfield);
}
return $context;
}
示例5: getCMSFields
/**
* CMS FIELDS
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$tab = 'Root.Main';
$field = new HTMLEditorField('PrimaryContent', 'Primary Content');
$fields->addFieldToTab($tab, $field);
$field = new HTMLEditorField('SecondaryContent', 'Secondary Content');
$fields->addFieldToTab($tab, $field);
$data = DataObject::get('Icon');
$field = new DropdownField('IconID', 'Swap Icon');
$field->setSource($data->map('ID', 'Name')->toArray());
$field->setEmptyString('Select one');
$fields->addFieldToTab($tab, $field);
return $fields;
}
示例6: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('ActiveItemID');
$tab = 'Root.Main';
$tab = 'Root.Examples';
// only need this field if there are items to choose from
if (count($this->ExampleDataModelItems()) > 0) {
$field = new DropdownField('ActiveItemID', 'Active Item');
$field->setSource($this->ExampleDataModelItems()->map('ID', 'FirstName')->toArray());
$field->setEmptyString('Select one');
$fields->addFieldToTab($tab, $field);
}
$conf = GridFieldConfig_RelationEditor::create(10);
$fields->addFieldToTab($tab, new GridField('ExampleDataModel', 'DataModels', $this->ExampleDataModelItems(), $conf));
return $fields;
}
示例7: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('DN');
$field = new DropdownField('DN', _t('LDAPGroupMapping.LDAPGROUP', 'LDAP Group'));
$field->setEmptyString(_t('LDAPGroupMapping.SELECTONE', 'Select one'));
$groups = $this->ldapService->getGroups(true, array('dn', 'name'));
if ($groups) {
foreach ($groups as $dn => $record) {
$source[$dn] = sprintf('%s (%s)', $record['name'], $dn);
}
}
asort($source);
$field->setSource($source);
$fields->addFieldToTab('Root.Main', $field);
$fields->removeByName('Scope');
$fields->addFieldToTab('Root.Main', new DropdownField('Scope', _t('LDAPGroupMapping.SCOPE', 'Scope'), array('Subtree' => _t('LDAPGroupMapping.SUBTREE_DESCRIPTION', 'Users within this group and all nested groups within'), 'OneLevel' => _t('LDAPGroupMapping.ONELEVEL_DESCRIPTION', 'Only users within this group'))));
return $fields;
}
示例8: getEditForm
/**
* Returns the edit form for this admin.
*
* @param type $id
* @param type $fields
*
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
$fields = new FieldList();
$desc = _t('SilvercartNewsletterRecipientsAdmin.Description', 'Please choose your export context and press the export button to download a CSV list of email recipients.');
$descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc));
$exportContextField = new DropdownField('ExportContext', _t('SilvercartNewsletterRecipientsAdmin.ExportContext', 'Export context'));
$exportContextField->setSource(array('0' => _t('SilvercartNewsletterRecipientsAdmin.ExportAll', 'Export all customers'), '1' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipients', 'Export all newsletter recipients'), '2' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithAccount', 'Export all newsletter recipients with customer account'), '3' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithoutAccount', 'Export all newsletter recipients without customer account'), '4' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNonNewsletterRecipients', 'Export all non-newsletter recipients')));
$doExportButton = new InlineFormAction('do_newsletter_recipients_export', _t('SilvercartNewsletterRecipientsAdmin.DoExport', 'Export as CSV'));
$doExportButton->includeDefaultJS(false);
$doExportButton->setAttribute('data-icon', 'download-csv');
$fields->push($descriptionField);
$fields->push($exportContextField);
$fields->push($doExportButton);
$actions = new FieldList();
$form = new Form($this, "EditForm", $fields, $actions);
$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
$form->loadDataFrom($this->request->getVars());
$this->extend('updateEditForm', $form);
return $form;
}
示例9: setSource
public function setSource($source)
{
if ($source) {
return parent::setSource($source);
}
// map empty source to country list
// Get a list of countries from Zend
$source = Zend_Locale::getTranslationList('territory', $this->locale(), 2);
// We want them ordered by display name, not country code
// PHP 5.3 has an extension that sorts UTF-8 strings correctly
if (class_exists('Collator') && ($collator = Collator::create($this->locale()))) {
$collator->asort($source);
} else {
// Otherwise just put up with them being weirdly ordered for now
asort($source);
}
// We don't want "unknown country" as an option
unset($source['ZZ']);
return parent::setSource($source);
}
示例10: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$tab = 'Root.Main';
$tab = 'Root.Examples';
$tab = 'Root.Examples.Color';
$field = new HtmlEditorField('ColorPrompt');
$fields->addFieldToTab($tab, $field);
$data = DataObject::get('Color');
$field = new DropdownField('MyColorID', 'My Color');
$field->setSource($data->map('ID', 'Name')->toArray());
$field->setEmptyString('Select one');
$fields->addFieldToTab($tab, $field);
$tab = 'Root.Examples.Icon';
$field = new HtmlEditorField('IconPrompt');
$fields->addFieldToTab($tab, $field);
$data = DataObject::get('Icon');
$field = new DropdownField('MyIconID', 'My Icon');
$field->setSource($data->map('ID', 'Name')->toArray());
$field->setEmptyString('Select one');
$fields->addFieldToTab($tab, $field);
return $fields;
}
示例11: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$tab = 'Root.Main';
$tab = 'Root.Examples';
// only need this field if there are items to choose from
if (count($this->Directives()) > 0) {
$field = new DropdownField('ActiveDirectiveID', 'Active Directive');
$field->setSource($this->Directives()->map('ID', 'Name')->toArray());
$field->setEmptyString('Select one');
$fields->addFieldToTab($tab, $field);
}
$conf = GridFieldConfig_RelationEditor::create(10);
$conf->removeComponentsByType('GridFieldAddNewButton');
$conf->addComponent(new GridFieldDeleteAction());
$conf->addComponent(new GridFieldAddNewMultiClass());
$conf->getComponentByType('GridFieldAddNewMultiClass')->setClasses($this->getAvailableDirectiveClasses());
$conf->removeComponentsByType('GridFieldPaginator');
$conf->removeComponentsByType('GridFieldPageCount');
$field = new GridField('AngularDirective', 'Directives', $this->Directives(), $conf);
$fields->addFieldToTab($tab, $field);
return $fields;
}
示例12: updateFields
public function updateFields(FieldList $fields)
{
if (!$this->owner->ID) {
return $fields;
}
$effective = $this->workflowService->getDefinitionFor($this->owner);
$tab = $fields->fieldByName('Root') ? $fields->findOrMakeTab('Root.Workflow') : $fields;
if (Permission::check('APPLY_WORKFLOW')) {
$definition = new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'));
$definition->setSource($this->workflowService->getDefinitions()->map());
$definition->setEmptyString(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
$tab->push($definition);
// $fields->addFieldToTab($tab, $definition);
}
$tab->push(new ReadonlyField('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $effective ? $effective->Title : _t('WorkflowApplicable.NONE', '(none)')));
if ($this->owner->ID) {
$config = new GridFieldConfig_Base();
$config->addComponent(new GridFieldEditButton());
$config->addComponent(new GridFieldDetailForm());
$insts = $this->owner->WorkflowInstances();
$log = new GridField('WorkflowLog', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log'), $insts, $config);
$tab->push($log);
}
}
示例13: setSource
public function setSource($source)
{
if ($source) {
$hasCommas = array_filter(array_keys($source), create_function('$key', 'return strpos($key, ",") !== FALSE;'));
if ($hasCommas) {
throw new InvalidArgumentException('No commas allowed in $source keys');
}
}
parent::setSource($source);
return $this;
}
示例14: 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
示例15: scaffoldFormField
public function scaffoldFormField($title = null, $params = null)
{
$selectBox = new DropdownField($this->name, $title);
$selectBox->setSource($this->getDefaultOptions());
return $selectBox;
}