Is there a way to use this module/widget in a custom form built with the form API?

Comments

czigor’s picture

Have you tried

$form = array(
  '#type' => 'mfw_managed_file',
...
);

?

czigor’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing this due to lack of feedback.

zelenovas’s picture

Trying make it work in my custom module with Form API... but it doesn't work :(
When I push the "Upload" button the throbber appears for a second and nothing more happens.
Can you tell me what am I doing wrong?

My module code for form function:

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;
}

My configuration:

  • Drupal 7.30
  • Multiupload Filefield Widget 7.x-1.13
  • Multiupload Imagefield Widget 7.x-1.3

Widget works great out of the box in node edit form.

Please help.
Thanks.

zelenovas’s picture

Status: Closed (won't fix) » Postponed (maintainer needs more info)
zelenovas’s picture

Status: Postponed (maintainer needs more info) » Postponed
paupale’s picture

Status: Postponed » Active

I created a new custom form

When I press "Upload" I have the same problem, the throbber appears and I get:

Notice: Undefined index: _0 in mfw_managed_file_save_upload() (line 147 of /home/paulius/sites/palevicius.lt/eurosplint/sites/all/modules/multiupload_filefield_widget/multiupload_filefield_widget.module).
Notice: Undefined index: _0 in mfw_managed_file_save_upload() (line 147 of /home/paulius/sites/palevicius.lt/eurosplint/sites/all/modules/multiupload_filefield_widget/multiupload_filefield_widget.module).

I also tried adding '#parents' = array('image', 'und', 0), but now only one file is visible after upload. Any ideas if it is possible to make this module work with FAPI?

parisek’s picture

This is good article how to solve this in custom module (without any module) - https://coderwall.com/p/rsv9ra/d7-multiple-file-upload