欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

How to add image field in form drupal 7

i am creating a form as shown in image which saves detail in csv in background by putting php code in body block which works fine but can anyone tell me how to add the image upload option in form and to save the same in other place

enter image description here

shareimprove this question
 

1 Answer 正确答案 

First do not add code in body block. Create a custom module.

To add image field please refer Drupal Form API.

Eg.

$form['image_example_image_fid'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
  '#default_value' => variable_get('image_example_image_fid', ''),
  '#upload_location' => 'public://image_example_images/',
);
shareimprove this answer
 
   
great.thanks a lot for commenting .i will go ahead with this hoping that we can add text fields as shown in image also.Is it fine? – pkm Jan 20 '14 at 5:17
1 

普通分类: