【问题标题】:How to use Multiupload Imagefield in Drupal 7 Form API?如何在 Drupal 7 Form API 中使用 Multiupload Imagefield?
【发布时间】:2014-07-26 08:14:44
【问题描述】:

我正在尝试使用表单 API 在我的 Drupal 7 自定义模块中使用 Multiupload Imagefield Widget... 但它不起作用:(

当我按下“上传”按钮时,悸动者会出现一秒钟,然后什么都没有发生,只是刷新页面。谁能告诉我我做错了什么?

我的模块表单功能:

<?php

function test_module_form($form, &$form_state) {
  $form = array();
  $form['image'] = array(
    '#title' => 'Upload image',
    '#type' => 'mfw_managed_file',
    '#upload_location' => 'public://images/',
    '#upload_validators' => array(
      'file_validate_is_image' => array(),
      'file_validate_extensions' => array('png gif jpg jpeg'),
      'file_validate_size' => array(2 * 1024 * 1024),
    ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );

  return $form;
}

?>

我使用全新安装:

  • Drupal 7.30
  • 多上传文件字段小部件 7.x-1.13
  • Multiupload Imagefield Widget 7.x-1.3

小部件在节点编辑表单中开箱即用,但在自定义模块中却不行。 请帮忙。谢谢。

【问题讨论】:

    标签: drupal drupal-7 filefield imagefield form-api


    【解决方案1】:

    认为 images 文件夹不可写。您确定 drupal 日志中没有错误吗?

    附言为什么不使用模块“Multiupload Imagefield”?

    【讨论】:

    • “mfw_managed_file”类型的表单域需要Multiupload Imagefield模块,不是吗?是的,按下“上传”按钮后,Drupal 日志中会出现 7 条通知。
    • Notice: Undefined index: in file_ajax_upload() (line 262 of Z:\home\drupal7.loc\www\modules\file\file.module). ----- Notice: Undefined index: fid in file_field_widget_submit() (line 773 of Z:\home\drupal7.loc\www\modules\file\file.field.inc). ----- Notice: Undefined index: field in field_widget_field() (line 578 of Z:\home\drupal7.loc\www\modules\field\field.form.inc).
    • Notice: Undefined index: instance in field_widget_instance() (line 603 of Z:\home\drupal7.loc\www\modules\field\field.form.inc). *** Notice: Undefined index: instance in field_widget_instance() (line 603 of Z:\home\drupal7.loc\www\modules\field\field.form.inc). *** Notice: Undefined index: in file_ajax_upload() (line 271 of Z:\home\drupal7.loc\www\modules\file\file.module). *** Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of Z:\home\drupal7.loc\www\modules\file\file.module).
    • 这些通知的截图:1st notice2nd notice3rd notice4th notice5th notice6th notice7th notice
    • P.S.:图片文件夹100%可写。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 2013-01-16
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多