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


PHP FieldDefinitionInterface::isRequired方法代码示例

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


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

示例1: formSingleElement

 /**
  * Generates the form element for a single copy of the widget.
  */
 protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 {
     $entity = $items->getEntity();
     $element += array('#field_parents' => $form['#parents'], '#required' => $delta == 0 && $this->fieldDefinition->isRequired(), '#delta' => $delta, '#weight' => $delta);
     $element = $this->formElement($items, $delta, $element, $form, $form_state);
     if ($element) {
         // Allow modules to alter the field widget form element.
         $context = array('form' => $form, 'widget' => $this, 'items' => $items, 'delta' => $delta, 'default' => $this->isDefaultValueWidget($form_state));
         \Drupal::moduleHandler()->alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context);
     }
     return $element;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:WidgetBase.php

示例2: isApplicable

 /**
  * {@inheritdoc}
  */
 public static function isApplicable(FieldDefinitionInterface $field_definition)
 {
     if (!$field_definition->isRequired()) {
         return FALSE;
     }
     $handler_settings = $field_definition->getSettings()['handler_settings'];
     // Entity types without bundles will throw notices on next condition so let's
     // stop before they do. We should support this kind of entities too. See
     // https://www.drupal.org/node/2569193 and remove this check once that issue
     // lands.
     if (empty($handler_settings['target_bundles'])) {
         return FALSE;
     }
     if (count($handler_settings['target_bundles']) != 1) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:21,代码来源:InlineEntityFormSimple.php


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