function _brightcove_field_video_widget_form in Brightcove Video Connect 7.5
Same name and namespace in other branches
- 7.7 brightcove_field.video.inc \_brightcove_field_video_widget_form()
- 7.3 brightcove_field/brightcove_field.video.inc \_brightcove_field_video_widget_form()
- 7.4 brightcove_field/brightcove_field.video.inc \_brightcove_field_video_widget_form()
- 7.6 brightcove_field.video.inc \_brightcove_field_video_widget_form()
1 call to _brightcove_field_video_widget_form()
- brightcove_field_field_widget_form in brightcove_field/
brightcove_field.module - Implements hook_field_widget_form().
File
- brightcove_field/
brightcove_field.video.inc, line 48 - Holds all of the video field related methods.
Code
function _brightcove_field_video_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, &$element) {
$entity_type = $element['#entity_type'];
$entity_info = entity_get_info($entity_type);
$eid = isset($form[$entity_info['entity keys']['id']]['#value']) ? $form[$entity_info['entity keys']['id']]['#value'] : NULL;
$bundle = isset($form[$entity_info['entity keys']['bundle']]['#value']) ? $form[$entity_info['entity keys']['bundle']]['#value'] : NULL;
// It needs to be able to work with field collection.
$parent_delta = array_pop($element['#field_parents']);
// We need this mixed variable in access checking.
$entity_id_or_bundle = !empty($eid) ? $eid : $bundle;
$element['brightcove_id'] = array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['brightcove_id']) ? $items[$delta]['brightcove_id'] : NULL,
'#title' => $element['#title'],
'#maxlength' => 256,
'#value_callback' => 'brightcove_field_video_browser_value',
'#autocomplete_path' => 'brightcove_field/autocomplete/video/' . $element['#entity_type'] . '/' . $element['#field_name'] . '/' . ($eid ? $eid : ($bundle ? $bundle : 0)),
'#attributes' => array(
'rel' => array(
$element['#field_name'] . '-' . $parent_delta . '-' . $delta,
),
'class' => array(
'brightcove-video-field',
$element['#field_name'] . '-' . $parent_delta . '-' . $delta,
),
'data-field-name' => $element['#field_name'],
),
'#element_validate' => array(
'brightcove_field_browser_video_validate',
),
'#field_name' => $element['#field_name'],
'#description' => $element['#description'],
);
if (brightcove_field_browse_access('browse videos', $entity_type, $field['field_name'], $entity_id_or_bundle)) {
// Button to browse videos.
$element['actions']['browse'] = array(
'#type' => 'button',
'#attributes' => array(
'class' => array(
'brightcove-field-browse-video-button',
),
'rel' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
'data-entity-type' => $entity_type,
'data-bundle' => $element['#bundle'],
'data-field-name' => $element['#field_name'],
'data-entity-id' => is_null($eid) ? '0' : $eid,
),
'#executes_submit_callback' => FALSE,
'#limit_validation_errors' => array(),
'#default_value' => t('Browse'),
'#value_callback' => 'brightcove_field_button_value_callback',
'#ajax' => array(
'callback' => 'ajax_browse_video_dialog_callback',
),
'#name' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
);
}
if (brightcove_field_browse_access('upload videos', $entity_type, $field['field_name'], $entity_id_or_bundle) && $instance['settings']['allow_upload']) {
$element['actions']['upload'] = array(
'#type' => 'button',
'#attributes' => array(
'class' => array(
'brightcove-field-upload-button',
),
'rel' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
'data-entity-type' => $entity_type,
'data-bundle' => $element['#bundle'],
'data-field-name' => $element['#field_name'],
'data-entity-id' => is_null($eid) ? '0' : $eid,
),
'#limit_validation_errors' => array(),
'#default_value' => t('Upload'),
'#value_callback' => 'brightcove_field_button_value_callback',
'#ajax' => array(
'callback' => 'ajax_upload_video_dialog_callback',
),
'#name' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
);
}
$element['actions']['remove'] = array(
'#type' => 'button',
'#attributes' => array(
'class' => array(
'brightcove-field-remove-button',
),
'rel' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
'data-entity-type' => $entity_type,
'data-field-name' => $element['#field_name'],
'data-entity-id' => is_null($eid) ? '0' : $eid,
),
'#default_value' => t('Remove'),
'#value_callback' => 'brightcove_field_button_value_callback',
'#name' => $element['#field_name'] . '-' . $parent_delta . '-' . $delta,
);
$element['player'] = array(
'#type' => $instance['settings']['per_content_player'] ? 'select' : 'value',
'#title' => t('Player'),
'#options' => brightcove_player_list($instance),
'#default_value' => isset($items[$delta]['player']) ? $items[$delta]['player'] : NULL,
);
if (!isset($element['#default_value'])) {
$element['actions']['remove']['#attributes']['disabled'] = 'disabled';
}
if (empty($brightcove_field_settings[$element['#field_name']])) {
$brightcove_field_settings[$element['#field_name']] = array(
'brightcove_field' => array(
$element['#field_name'] => array(
'entity_type' => $entity_type,
'field_name' => $element['#field_name'],
'entity_id' => is_null($eid) ? '0' : $eid,
),
),
);
}
$element['brightcove_id']['#attached']['library'] = array(
array(
'system',
'ui.dialog',
),
);
$element['brightcove_id']['#attached']['css'] = array(
drupal_get_path('module', 'brightcove_field') . '/styles/brightcove.css',
);
$element['brightcove_id']['#attached']['js'] = array(
drupal_get_path('module', 'brightcove_field') . '/js/brightcove.js',
);
$element['brightcove_id']['#attached']['js'][] = array(
'data' => $brightcove_field_settings[$element['#field_name']],
'type' => 'setting',
);
}