本文整理汇总了PHP中Drupal\Core\Field\FieldItemBase::fieldSettingsForm方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldItemBase::fieldSettingsForm方法的具体用法?PHP FieldItemBase::fieldSettingsForm怎么用?PHP FieldItemBase::fieldSettingsForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Field\FieldItemBase
的用法示例。
在下文中一共展示了FieldItemBase::fieldSettingsForm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fieldSettingsForm
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state)
{
$element = parent::fieldSettingsForm($form, $form_state);
$range = $this->getSetting('range');
$element['range'] = array('#type' => 'textfield', '#title' => t('Range'), '#description' => t('The range of weights available to select. For
example, a range of 20 will allow you to select a weight between -20
and 20.'), '#default_value' => $range, '#size' => 5);
return $element;
}
示例2: fieldSettingsForm
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state)
{
$element = parent::fieldSettingsForm($form, $form_state);
$mc_list_id = $this->getFieldDefinition()->getSetting('mc_list_id');
if (empty($mc_list_id)) {
drupal_set_message(t('Select a list to sync with on the Field Settings tab before configuring the field instance.'), 'error');
return $element;
}
$this->definition;
$instance_settings = $this->definition->getSettings();
$element['show_interest_groups'] = array('#title' => "Enable Interest Groups", '#type' => "checkbox", '#default_value' => $instance_settings['show_interest_groups']);
$element['interest_groups_label'] = array('#title' => "Interest Groups Label", '#type' => "textfield", '#default_value' => !empty($instance_settings['show_interest_groups']) ? $instance_settings['show_interest_groups'] : 'Interest Groups');
$element['merge_fields'] = array('#type' => 'fieldset', '#title' => t('Merge Fields'), '#description' => t('Multi-value fields will only sync their first value to Mailchimp, as Mailchimp does not support multi-value fields.'), '#tree' => TRUE);
$element['unsubscribe_on_delete'] = array('#title' => "Unsubscribe on deletion", '#type' => "checkbox", '#description' => t('Unsubscribe entities from this list when they are deleted.'), '#default_value' => $instance_settings['unsubscribe_on_delete']);
$mv_defaults = $instance_settings['merge_fields'];
$mergevars = mailchimp_get_mergevars(array($mc_list_id));
$fields = $this->getFieldmapOptions($this->getFieldDefinition()->entity_type, $this->getFieldDefinition()->bundle);
$required_fields = $this->getFieldmapOptions($this->getFieldDefinition()->entity_type, $this->getFieldDefinition()->bundle, TRUE);
// Prevent this subscription field appearing as a merge field option.
$field_name = $this->getFieldDefinition()->getName();
unset($fields[$field_name]);
$fields_flat = OptGroup::flattenOptions($fields);
foreach ($mergevars[$mc_list_id]['merge_vars'] as $mergevar) {
$default_value = isset($mv_defaults[$mergevar['tag']]) ? $mv_defaults[$mergevar['tag']] : -1;
$element['merge_fields'][$mergevar['tag']] = array('#type' => 'select', '#title' => SafeMarkup::checkPlain($mergevar['name']), '#default_value' => array_key_exists($default_value, $fields_flat) ? $default_value : '', '#required' => $mergevar['req']);
if (!$mergevar['req'] || $mergevar['tag'] === 'EMAIL') {
$element['merge_fields'][$mergevar['tag']]['#options'] = $fields;
if ($mergevar['tag'] === 'EMAIL') {
$element['merge_fields'][$mergevar['tag']]['#description'] = t('Any entity with an empty or invalid email address field value will simply be ignored by the Mailchimp subscription system. <em>This is why the Email field is the only required merge field which can sync to non-required fields.</em>');
}
} else {
$element['merge_fields'][$mergevar['tag']]['#options'] = $required_fields;
$element['merge_fields'][$mergevar['tag']]['#description'] = t("Only 'required' and 'calculated' fields are allowed to be synced with Mailchimp 'required' merge fields.");
}
}
return $element;
}