function mediafront_field_form in MediaFront 7.2
Returns the mediafront field form.
2 calls to mediafront_field_form()
- mediafront_form_field_ui_field_edit_form_alter in includes/
mediafront.field.inc - Implementation of hook_form_FORM_ID_alter().
- mediafront_form_views_ui_config_item_form_alter in views/
mediafront.views.inc - Allow them to say which field they would like to use for certain MediaFront player fields.
File
- ./
mediafront.module, line 389
Code
function mediafront_field_form($options, $id_prefix = '') {
// Include CTools dependent
ctools_include('dependent');
// Get the field types.
$field_types = array(
0 => 'None',
'title' => 'Title',
'media' => 'Media',
'image' => 'Image',
'stream' => 'Stream',
'custom' => 'Custom',
);
// Get the field type for this field to map to mediafront.
$type = !empty($options['field_type']) ? $options['field_type'] : 0;
$form['field_type'] = array(
'#type' => 'select',
'#title' => 'Field Type',
'#description' => t('Select the way this field should be handled by a MediaFront player.'),
'#options' => $field_types,
'#default_value' => $type,
);
// Select the media type for the media.
$media_type = !empty($options['media_type']) ? $options['media_type'] : 'media';
$form['media_type'] = mediafront_media_field_form($media_type);
$form['media_type']['#process'] = array(
'ctools_dependent_process',
);
$form['media_type']['#dependency'] = array(
$id_prefix . 'field-type' => array(
'media',
),
);
// Add the preview image form.
$preview = !empty($options['preview']) ? $options['preview'] : 0;
$thumb = !empty($options['thumbnail']) ? $options['thumbnail'] : 0;
$form = array_merge($form, mediafront_preview_field_form($preview, $thumb));
// Add the CTools dependency on the preview and thumbnail selections.
$form['preview']['#process'] = array(
'ctools_dependent_process',
);
$form['preview']['#dependency'] = array(
$id_prefix . 'field-type' => array(
'image',
),
);
$form['thumbnail']['#process'] = array(
'ctools_dependent_process',
);
$form['thumbnail']['#dependency'] = array(
$id_prefix . 'field-type' => array(
'image',
),
);
// Add the custom data form.
$custom = !empty($options['custom']) ? $options['custom'] : "";
$form['custom'] = array(
'#type' => 'textfield',
'#title' => 'Field Name',
'#description' => 'Enter the machine name for the field you would like to bring into the media player.',
'#default_value' => $custom,
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
$id_prefix . 'field-type' => array(
'custom',
),
),
);
// Always show the player for any media attached to this entity.
$form['always_show_player'] = array(
'#type' => 'checkbox',
'#title' => t('Always show player for any media attached to this entity'),
'#default_value' => !empty($options['always_show_player']) ? $options['always_show_player'] : 0,
);
// Return the form.
return $form;
}