Media

问题描述 投票:0回答:1
) - when I select

Content I choose a title of content from a select list. - When I select Media I shoose from src (Image or video). I want when I select Content , the value of src changed to "_none". In the same case , when I choose Media the select list (title) default value be "_none". In this case when I switch between Content and media I dont have any previous field selected (title or src).My problem now is when I select title from the list, and try to change to select Media and choose Image. I got the title (previous selected ) and the Image. I just want to get one field. My code : I check the value of A , if for exemple Content value = 10 I change the default value of src to '_none'. value of Media = 11. I have a paragraph contain select list and two fields: A: with options (Content 如何在hook_field_widget_WIDGET_TYPE_form_alter中更改选择列表的默认值。

我有一个段落包含选择列表和两个字段,请问这两个字段是什么意思? A: 带选项(

// $val value of selected option
$val =(int) $element['subform']['field_a']['widget']['#default_value'][0];
// if Content is selected
if ($val == 10){
   // change default value of src to none 
   $element['subform']['field_src']['widget']['#default_value']= '_none';
}else{
   // change default value of title to none 
   $element['subform']['field_title']['widget']['#default_value']= '_none';
}

内容
drupal drupal-8 drupal-modules drupal-hooks
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.