繁体   English   中英

Drupal 8 如何改变段落形式?

[英]Drupal 8 how to alter paragraph form?

在 drupal 8 中,我在节点中使用段落。 它工作正常,但我坚持改变段落形式。 我想根据其他字段值隐藏一个字段。

如果有人以前做过,请帮忙

我发现下面的代码很有帮助并解决了我的问题。 我希望它对其他人也有用。

 function hook_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) { // $entity_form['#bundle'] paragraph machine name if($entity_form['#entity_type'] == 'paragraph' && $entity_form['#bundle'] == 'location'){ $parents = $entity_form['#parents']; $identifier = $parents[0].'['.implode('][', array_slice($parents, 1)).']'; $entity_form['field_dropoff_time']['#states'] = array( 'visible' => array( 'select[name="'. $identifier .'[field_camp_location_type]"]' => ['value' => 1] ), ); $entity_form['field_pickup_time']['#states'] = array( 'visible' => array( 'select[name="'. $identifier .'[field_camp_location_type]"]' => ['value' => 1] ), ); } }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM