Last active
May 16, 2016 15:16
-
-
Save mbopp/ed3a596f629256d51996d5b3470284e7 to your computer and use it in GitHub Desktop.
Contributed Field Widget in Custom Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$field = field_info_field('field_some_youtube_video'); | |
$instance = field_info_instance('node','field_some_youtube_video','custom_video'); | |
$items = array(); | |
if (isset($node->field_some_youtube_video[LANGUAGE_NONE][0])) { | |
$items = $node->field_some_youtube_video[LANGUAGE_NONE]; | |
} | |
$form['#parents'] = array(); // a required element to use 'field_default_form' function below. | |
$video_field = field_default_form('node', $node, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state); | |
$form['video'] = $video_field['field_some_youtube_video']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment