function brightcove_field_browser_process in Brightcove Video Connect 7.6
Same name and namespace in other branches
- 7.7 brightcove.module \brightcove_field_browser_process()
- 7.2 brightcove_field/brightcove_field.module \brightcove_field_browser_process()
- 7.3 brightcove_field/brightcove_field.module \brightcove_field_browser_process()
- 7.4 brightcove_field/brightcove_field.module \brightcove_field_browser_process()
- 7.5 brightcove_field/brightcove_field.module \brightcove_field_browser_process()
Brightcove field form that returns the actual field to the user. Parts of this and subsequent JS taken from Nodereference Explorer. Thanks!
1 string reference to 'brightcove_field_browser_process'
- brightcove_element_info in ./
brightcove.module - Implements hook_element_info().
File
- ./
brightcove.module, line 766 - Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.
Code
function brightcove_field_browser_process($element, $form_state, $form) {
$field_key = $element['#columns'][0];
$entity_type = $form['#entity_type'];
$entity_info = entity_get_info($entity_type);
$eid = $form[$entity_info['entity keys']['id']]['#value'];
$field_info = field_info_field($element['#field_name']);
$element[$field_key] = [
'#type' => 'textfield',
'#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '',
'#autocomplete_path' => 'brightcove_field/autocomplete/' . $element['#field_name'] . '/' . $element['#entity_type'] . '/' . $eid,
'#maxlength' => 256,
// The following values were set by the content module and need
// to be passed down to the nested element.
'#title' => $element['#title'],
'#required' => $element['#required'],
'#description' => $element['#description'],
'#field_name' => $element['#field_name'],
'#delta' => $element['#delta'],
'#columns' => $element['#columns'],
'#attributes' => [
'rel' => $element['#field_name'],
'class' => [
'brightcove-video-field',
],
],
];
if (user_access('browse videos')) {
// Button to browse videos.
$element['actions']['browse'] = [
'#type' => 'brightcove_field_browse_button',
'#id' => $element['#id'] . '-browse',
'#attributes' => [
'class' => [
'brightcove-field-browse-button',
],
'rel' => $element['#id'] . '-video-id',
],
'#value' => t('Browse'),
];
}
if (user_access('upload videos')) {
$element['actions']['upload'] = [
'#type' => 'brightcove_field_browse_button',
'#id' => $element['#id'] . '-upload',
'#attributes' => [
'class' => [
'brightcove-field-upload-button',
],
'rel' => $element['#id'] . '-video-id',
],
'#value' => t('Upload'),
];
}
$element['actions']['remove'] = [
'#type' => 'brightcove_field_browse_button',
'#id' => $element['#id'] . '-remove',
'#attributes' => [
'class' => [
'brightcove-field-remove-button',
],
'rel' => $element['#id'] . '-video-id',
],
'#value' => t('Remove'),
];
if (!isset($element['#default_value'][$field_key])) {
$element['actions']['remove']['#attributes']['disabled'] = 'disabled';
}
if (empty($brightcove_field_settings[$element['#field_name']])) {
$brightcove_field_settings[$element['#field_name']] = [
'brightcove_field' => [
$element['#field_name'] => [
'entity_type' => $entity_type,
'field_name' => $element['#field_name'],
'entity_id' => $eid,
],
],
];
drupal_add_js($brightcove_field_settings[$element['#field_name']], [
'type' => 'setting',
]);
}
if (empty($element[$field_key]['#element_validate'])) {
$element[$field_key]['#element_validate'] = [];
}
array_unshift($element[$field_key]['#element_validate'], 'brightcove_field_browser_video_validate');
return $element;
}