I'm trying to create a custom field type which has several elements, one of which is an image. Is it possible to use an image field type within this form somehow? Most of the resources I find tell me to use a managed_file, but it seems I have to manage my own file in this case? As in move it from temp to public storage, create file_usage instances, and such? I don't really want to do that if I don't have to :)

As an example, I'd like to have something like the following in my hook_field_widget_form():

$element['iid'] = array(
    '#title' => 'Image',
    '#type'  => 'image',

I would also like to employ other features of the image field type, such as alt text and styles.

Edit: I should add that I've taken a look at the field_collection module, however the client I am working for has specified that modules without a solid version (those tagged as alpha, beta, or dev) are not to be used.

Edit 2: Looks like there's no way of using custom field types within your own custom field type. I ended up doing the file management myself by taking a peek at how the Image module does it's file management. Unfortunatey this means that I'm not taking advantage of image styles, although it looks like I could potentially do that by hand as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.