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); } }
public function setSource($source) { parent::setSource($source); if (!$source instanceof SS_Map) { throw new Exception('SS_Map'); } $this->toggleStar(); return $this; }
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; }
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; }
/** * 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; }
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; }
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; }
/** * 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; }
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); }
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; }
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; }
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); } }
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; }
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; }
public function scaffoldFormField($title = null, $params = null) { $selectBox = new DropdownField($this->name, $title); $selectBox->setSource($this->getDefaultOptions()); return $selectBox; }
public function StartForm() { $databaseTemplates = $this->getDatabaseTemplates(); $fields = new FieldList(new CheckboxField('createDatabase', 'Create temporary database?', 1)); if ($databaseTemplates) { $fields->push($dropdown = new DropdownField('importDatabasePath', false)); $dropdown->setSource($databaseTemplates)->setEmptyString('Empty database'); } $fields->push(new CheckboxField('requireDefaultRecords', 'Create default data?')); if (Director::isDev()) { $fields->push(CheckboxField::create('globalTestSession', 'Use global test session?')->setDescription('Caution: Will apply to all users across browsers')); } $fields->merge($this->getBaseFields()); $form = new Form($this, 'StartForm', $fields, new FieldList(new FormAction('start', 'Start Session'))); $this->extend('updateStartForm', $form); return $form; }
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')); }