當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。