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


PHP WidgetBase::formMultipleElements方法代码示例

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


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

示例1: formMultipleElements

 /**
  * {@inheritdoc}
  */
 protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 {
     // Adjust wrapper identifiers as they are shared between parents and
     // children in nested field collections.
     $form['#wrapper_id'] = Html::getUniqueID($items->getName());
     $elements = parent::formMultipleElements($items, $form, $form_state);
     $elements['#prefix'] = '<div id="' . $form['#wrapper_id'] . '">';
     $elements['#suffix'] = '</div>';
     $elements['add_more']['#ajax']['wrapper'] = $form['#wrapper_id'];
     return $elements;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:14,代码来源:FieldCollectionEmbedWidget.php

示例2: formMultipleElements

 /**
  * {@inheritdoc}
  */
 protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 {
     // We don't want to render empty items on field collection fields
     // unless a) the field collection is empty ; b) the form is rebuilding,
     // which means that the user clicked on "Add another item"; or
     // c) we are creating a new entity.
     if (count($items) > 0 && !$form_state->isRebuilding() && !$items->getEntity()->isNew()) {
         $field_name = $this->fieldDefinition->getName();
         $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
         $parents = $form['#parents'];
         if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
             $field_state = static::getWidgetState($parents, $field_name, $form_state);
             $field_state['items_count']--;
             static::setWidgetState($parents, $field_name, $form_state, $field_state);
         }
     }
     // Adjust wrapper identifiers as they are shared between parents and
     // children in nested field collections.
     $form['#wrapper_id'] = Html::getUniqueID($items->getName());
     $elements = parent::formMultipleElements($items, $form, $form_state);
     $elements['#prefix'] = '<div id="' . $form['#wrapper_id'] . '">';
     $elements['#suffix'] = '</div>';
     $elements['add_more']['#ajax']['wrapper'] = $form['#wrapper_id'];
     return $elements;
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:28,代码来源:FieldCollectionEmbedWidget.php


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