我正在尝试为文本字段创建一个新的自定义字段格式化程序,但根本没有显示任何内容.
我尝试卸载并重新安装模块并多次刷新缓存,但没有任何效果.
这是我使用的代码
/**
* Implementation of hook_field_formatter_info()
*/
function facebooklink_field_formatter_info()
{
return array(
'cfieldformatter_text_1' => array(
'label' => t('Text 1'),
'field types' => array('text', 'text_long', 'text_with_summary'),
'settings' => array(
'pic_size' => 'small',
'tooltip' => 'Link to user Facebook page',
),
),
);
}
/**
* Implementation of hook_field_formatter_settings_form()
*/
function facebooklink_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
{
//This gets the view_mode where our settings are stored
$display = $instance['display'][$view_mode];
//This gets the actual settings
$settings = $display['settings'];
//Initialize the element …Run Code Online (Sandbox Code Playgroud) drupal drupal-7 drupal-field-api drupal-fields drupal-modules
我为Drupal 8创建了一个自定义模块,该模块允许用户选择一种Content类型,以便以编程方式添加一些字段。如何创建一些字段(在这种情况下为文本类型),并使用自定义模块将它们附加到内容类型?
一些帮助?
谢谢。
我本质上是尝试使用新的Drupal 7 Field API创建我的第一个字段类型模块.我设法让它在"编辑"视图中正确显示.
但是,当我尝试保存一些数据时,它只保存第一个字符.
这是模块:
<?php
function youtubefield_field_info() {
return array(
'youtubefield_video' => array(
'label' => t('Youtube video'),
'description' => t('This field stores a youtube video ID and displays the video associated with it'),
'settings' => array(
'max_length' => 11,
),
'instance_settings' => array(
'text_processing' => false,
),
'default_widget' => 'youtubefield_video_widget',
'default_formatter' => 'youtubefield_video_formatter',
),
);
}
function youtubefield_field_widget_info() {
return array(
'youtubefield_video_widget' => array(
'label' => t('Default'),
'field types' => array('youtubefield_video'),
),
);
}
function youtubefield_field_widget_form(&$form, &$form_state, $field, …Run Code Online (Sandbox Code Playgroud) 我正在使用Drupal 7字段API,这似乎很棒:我可以为"用户"实体类型添加自定义字段,并在GUI中进行编辑.
我field_get_items($entity_type, $entity, $field)用来获取自定义字段值.
我现在需要以编程方式设置我的自定义字段的值.
我怎么做?我field_set_items()在Drupal API文档中的任何地方都找不到函数调用.
我想开发一个模块,在drupal 7中为用户配置文件添加字段,如电话号码和CV ......我不知道该怎么做(使用数据库或使用字段API)请帮助我.
任何明确的教程将不胜感激.