You are here

function paragraphs_pack_add_field_view_mode in Paragraphs pack 7

Adds view mode field to a paragraph bundle.

Parameters

string $bundle: A paragraph type machine_name.

$field_label: A label of the field.

$entity_type: An entity type which view modes are displayed.

Return value

array An view mode field instance.

4 calls to paragraphs_pack_add_field_view_mode()
ParagraphsPackTestCase::testParagraphsPackFieldViewModeInstanceCreation in tests/paragraphs_pack.test
Test function for field view mode 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 212
Fields CRUD functions.

Code

function paragraphs_pack_add_field_view_mode($bundle, $field_label, $entity_type = 'node') {
  $field = paragraphs_pack_get_field_view_mode();
  $instance = _paragraphs_pack_add_field(array(
    'field_name' => $field['field_name'],
    'entity_type' => PP_PARAGRAPH_TYPE,
    'bundle' => $bundle,
    'label' => $field_label,
    'settings' => array(
      'entity_type' => $entity_type,
    ),
    'required' => TRUE,
    'display' => array(
      'default' => array(
        'label' => 'hidden',
        'settings' => array(),
        'type' => 'hidden',
        'weight' => -10,
      ),
      'paragraphs_editor_preview' => array(
        'label' => 'hidden',
        'settings' => array(),
        'type' => 'hidden',
        'weight' => -10,
      ),
    ),
  ));
  return $instance;
}