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


PHP FieldTypePluginManagerInterface::getUiDefinitions方法代码示例

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


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

示例1: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL)
 {
     if (!$form_state->get('entity_type_id')) {
         $form_state->set('entity_type_id', $entity_type_id);
     }
     if (!$form_state->get('bundle')) {
         $form_state->set('bundle', $bundle);
     }
     $this->entityTypeId = $form_state->get('entity_type_id');
     $this->bundle = $form_state->get('bundle');
     // Gather valid field types.
     $field_type_options = array();
     foreach ($this->fieldTypePluginManager->getGroupedDefinitions($this->fieldTypePluginManager->getUiDefinitions()) as $category => $field_types) {
         foreach ($field_types as $name => $field_type) {
             $field_type_options[$category][$name] = $field_type['label'];
         }
     }
     $form['add'] = array('#type' => 'container', '#attributes' => array('class' => array('form--inline', 'clearfix')));
     $form['add']['new_storage_type'] = array('#type' => 'select', '#title' => $this->t('Add a new field'), '#options' => $field_type_options, '#empty_option' => $this->t('- Select a field type -'));
     // Re-use existing field.
     if ($existing_field_storage_options = $this->getExistingFieldStorageOptions()) {
         $form['add']['separator'] = array('#type' => 'item', '#markup' => $this->t('or'));
         $form['add']['existing_storage_name'] = array('#type' => 'select', '#title' => $this->t('Re-use an existing field'), '#options' => $existing_field_storage_options, '#empty_option' => $this->t('- Select an existing field -'));
         $form['#attached']['drupalSettings']['existingFieldLabels'] = $this->getExistingFieldLabels(array_keys($existing_field_storage_options));
     } else {
         // Provide a placeholder form element to simplify the validation code.
         $form['add']['existing_storage_name'] = array('#type' => 'value', '#value' => FALSE);
     }
     // Field label and field_name.
     $form['new_storage_wrapper'] = array('#type' => 'container', '#states' => array('!visible' => array(':input[name="new_storage_type"]' => array('value' => ''))));
     $form['new_storage_wrapper']['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#size' => 15);
     $field_prefix = $this->config('field_ui.settings')->get('field_prefix');
     $form['new_storage_wrapper']['field_name'] = array('#type' => 'machine_name', '#field_prefix' => '<span dir="ltr">' . $field_prefix, '#field_suffix' => '</span>&lrm;', '#size' => 15, '#description' => $this->t('A unique machine-readable name containing letters, numbers, and underscores.'), '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix), '#machine_name' => array('source' => array('new_storage_wrapper', 'label'), 'exists' => array($this, 'fieldNameExists')), '#required' => FALSE);
     // Provide a separate label element for the "Re-use existing field" case
     // and place it outside the $form['add'] wrapper because those elements
     // are displayed inline.
     if ($existing_field_storage_options) {
         $form['existing_storage_label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#size' => 15, '#states' => array('!visible' => array(':input[name="existing_storage_name"]' => array('value' => ''))));
     }
     // Place the 'translatable' property as an explicit value so that contrib
     // modules can form_alter() the value for newly created fields. By default
     // we create field storage as translatable so it will be possible to enable
     // translation at field level.
     $form['translatable'] = array('#type' => 'value', '#value' => TRUE);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save and continue'), '#button_type' => 'primary');
     $form['#attached']['library'][] = 'field_ui/drupal.field_ui';
     return $form;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:52,代码来源:FieldStorageAddForm.php


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