Hi
I need to create a field that will consist of two elements:
- standard file upload input
- select list with destination paths.
The file would be saved in localisation according to selected option
for examle:
private://file_type_1/
where "file_type_1" comes from the selection list.
Is it possible to achieve this by create new widget for file field?
Or do I have to create from scratch a new field type with widget using not managed_file type but regular file type?

Comments

da_solver’s picture

Hi,
I would read this carefully http://drupal.org/node/644164.

Afterwards, please edit your post and move it to the "Post Installtion" forum. That's where folks can discuss existing Drupal functionality (and it's configuration).

The forum you've posted in, is for developers who have analyzed Drupal's existing functionality and compared that functionality to their specific requirements. If the result of that comparison is, the required functionality does not exist, then folks begin to program a Drupal "module" (functional extension). When folks have specific questions regarding use of the Drupal API, they post their questions here.

You'll get the best answers but posting in the correct forum :)

Hope that helps.
Thank you for sharing

jaypan’s picture

Actually in this case I think he is asking about coding.

Contact me to contract me for D7 -> D10/11 migrations.

rulespl’s picture

This is definitely code question.
I'll try to explain it again:
In File module standard widget form for File Field is generated by managed_file type (file.field.inc):

function file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
...
  $element += array(
    '#type' => 'managed_file',
    '#upload_location' => file_field_widget_uri($field, $instance),
    '#upload_validators' => file_field_widget_upload_validators($field, $instance),
    '#value_callback' => 'file_field_widget_value',
    '#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
    '#progress_indicator' => $instance['widget']['settings']['progress_indicator'],
    // Allows this field to return an array instead of a single value.
    '#extended' => TRUE,
  );
...
}

I notice attribute '#upload_location' . I'm not sure but that mean file path must be specified when the widget form elements definition and can't by change later due to the drop-down selection.
My question is:
Can I override this widget form and add select list element with specyfic paths?
Or build new field type and use standard file type element not managed_file for widget?