function paragraphs_pack_add_field_items in Paragraphs pack 7
Adds items field to a paragraph bundle.
Parameters
string $bundle: A paragraph type machine_name.
$field_label: A label of the field.
Return value
array An items field instance.
4 calls to paragraphs_pack_add_field_items()
- ParagraphsPackTestCase::testParagraphsPackFieldItemsInstanceCreation in tests/
paragraphs_pack.test - Test function for field items instance creation.
- paragraphs_pack_node_list_install in modules/
paragraphs_pack_node_list/ paragraphs_pack_node_list.install - Implements hook_install().
- paragraphs_pack_taxonomy_term_list_install in modules/
paragraphs_pack_taxonomy_term_list/ paragraphs_pack_taxonomy_term_list.install - Implements hook_install().
- paragraphs_pack_user_list_install in modules/
paragraphs_pack_user_list/ paragraphs_pack_user_list.install - Implements hook_install().
File
- includes/
paragraphs_pack.fields_crud.inc, line 142 - Fields CRUD functions.
Code
function paragraphs_pack_add_field_items($bundle, $field_label, $target_type = 'node') {
$field = paragraphs_pack_get_field_items($target_type);
$instance = _paragraphs_pack_add_field(array(
'field_name' => $field['field_name'],
'entity_type' => PP_PARAGRAPH_TYPE,
'bundle' => $bundle,
'label' => $field_label,
'widget' => array(
'type' => 'entityreference_autocomplete',
),
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'paragraphs_pack',
'settings' => array(
'entity_type' => $target_type,
),
'type' => PP_FORMATTER_VIEW_MODE,
),
'paragraphs_editor_preview' => array(
'label' => 'hidden',
'module' => 'paragraphs_pack',
'settings' => array(
'entity_type' => $target_type,
),
'type' => PP_FORMATTER_VIEW_MODE,
),
),
));
return $instance;
}