public function VimeoSettingsForm::addContentTypeField in Vimeo Video Uploader 8.4
Same name and namespace in other branches
- 8 src/Form/VimeoSettingsForm.php \Drupal\vimeo_video_uploader\Form\VimeoSettingsForm::AddContentTypeField()
Add form fields in selected content type.
1 call to VimeoSettingsForm::addContentTypeField()
- VimeoSettingsForm::submitForm in src/
Form/ VimeoSettingsForm.php - Form submission handler.
File
- src/
Form/ VimeoSettingsForm.php, line 164
Class
- VimeoSettingsForm
- Provide configuration form for user to provide vimeo API information for a.
Namespace
Drupal\vimeo_video_uploader\FormCode
public function addContentTypeField($bundle) {
FieldStorageConfig::create([
'field_name' => 'field_vimeo_file_browse',
'entity_type' => 'node',
'type' => 'file',
])
->save();
FieldConfig::create([
'field_name' => 'field_vimeo_file_browse',
'entity_type' => 'node',
'bundle' => $bundle,
'settings' => [
'file_extensions' => 'mp4 mov wmv avi flv',
],
'label' => 'Browse video for uploading to Vimeo',
])
->save();
entity_get_form_display('node', $bundle, 'default')
->setComponent('field_vimeo_file_browse', [
'type' => 'file_generic',
])
->save();
entity_get_display('node', $bundle, 'default')
->setComponent('field_vimeo_file_browse', [
'type' => 'file_default',
])
->save();
// Add embedded video input field.
FieldStorageConfig::create([
'field_name' => 'field_embeddedvideo',
'entity_type' => 'node',
'type' => 'video_embed_field',
])
->save();
FieldConfig::create([
'field_name' => 'field_embeddedvideo',
'entity_type' => 'node',
'bundle' => $bundle,
'label' => 'Vimeo video link',
])
->save();
entity_get_form_display('node', $bundle, 'default')
->setComponent('field_embeddedvideo', [
'type' => 'video_embed_field_textfield',
'class' => 'neera',
])
->save();
entity_get_display('node', $bundle, 'default')
->setComponent('field_embeddedvideo', [
'type' => 'video_embed_field_video',
])
->save();
}