I am creating a field type that uploads a video file to Youtube upon post submission. I plan to use a file upload input type, and upon submission grab the file data (or url/pathname) and upload it to Youtube. This is part of a client project that I have to build in three weeks.
I've created a custom field by using the following hooks:
add_action("gform_field_input", array('GFYoutubeUpload', 'add_gf_fieldtype'), 10, 5);
add_filter("gform_editor_js_set_default_values", array('GFYoutubeUpload', 'add_gf_def
add_action("gform_editor_js", array('GFYoutubeUpload', 'add_gf_formeditor'));
add_filter("gform_field_type_title", array('GFYoutubeUpload', 'add_gf_title'));
add_filter("gform_add_field_buttons", array('GFYoutubeUpload', 'add_gf_button'));
(I also have a pre_submission handler that I've begun to write.)
I've created a File input type, and I believe that I have the correct naming convention. I've posted my function below for review.) The input type is displaying correctly on the admin page and the form preview, but when I post the form, my custom field doesn't have a value associated with it. (There's nothing in $_POST corresponding to it, either.)
Looking at the code below, can anybody tell me where I've gone wrong creating this input? Is there another hook that I don't know about that I need to use to handle the data I've added to the form?
/* Register the cusitom field type with Gravity Forms. */
public static function add_gf_fieldtype($input, $field, $value, $lead_id, $form_id) {
if ($field["type"] == "youtube") {
$input_name = $form_id .'_'. $field['id'];
$css = isset($field['cssClass']) ? $field['cssClass'] : '';
return sprintf("<div class='ginput_container'><input name='input_%s' id='input_%s_%s' class='%s' value='' type='file' /></div>", $field["id"], $form_id, $field["id"], $field["type"]. ' ' .esc_attr($css). ' ' .$field['size']);
}
return $input;
}
Thank you.