大佬教程收集整理的这篇文章主要介绍了未定义的函数 'field_widget_instance,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在 Drupal 9 Migration 自定义模块中出错
function sun_link_fIEld_process($element,$form_state,$complete_form) {
$instance = fIEld_Widget_instance($element,$form_statE);
$setTings = $instance['setTings'];
这是 Drupal 7 字段 API,它只需要转换为 D9.x。还要注意,它现在非常不同,需要在一个类中并使用 Annotations 才能正确定义。
几天前我看到有人问过一个叫“samtech”的人问过这个完全相同的功能;
function sun_link_field_process($element,$form_state,$complete_form) {
$instance = **field_widget_instance**($element,$form_statE);
$setTings = $instance['setTings'];
$attributes = isset($element['#value']['attributes']) ? $element['#value']['attributes'] : $setTings['attributes'];
$element['attributes']['link_classes'] = array(
'#type' => 'textfield','#title' => t('Custom link classes'),'#description' => t('A space delimited list of custom classes to be applied to the link.'),'#default_value' => isset($attributes['link_classes']) ? $attributes['link_classes'] : '','#field_prefix' => 'class="','#field_suffix' => '"',);
return $element;
}
假设这是完整的功能,只需查看 /core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php 以了解如何在 D9 中的表单小部件元素上应用“流程”。但请注意,您的函数根本存在表明该字段的其余部分也没有正确定义?
/**
* Form API callBACk: Processes an image_image field element.
*
* Expands the image_image type to include the alt and title fields.
*
* This method is assigned as a #process callBACk in formElement() method.
*/
public static function process($element,FormStateInterface $form_state,$form) {
以上是大佬教程为你收集整理的未定义的函数 'field_widget_instance全部内容,希望文章能够帮你解决未定义的函数 'field_widget_instance所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。