1

Re: Supporting uploads

Hi,

I'm new to using indicia and I'm trying to setup IForm with Drupal to submit occurrences (currently to the test warehouse).

With each occurrence we need to submit a photo, but possibly 2 photos.

I've gone through the steps documented here (http://code.google.com/p/indicia/wiki/UsingDrupalIForm) and generated a data entry form but there doesn't seem to be any associated file upload component.

How can I add one or more upload fields to the form?

Chris.

2

Re: Supporting uploads

Hi Chris

The Basic 1 form that is used in the document you quote does not include a file upload control. You have two options: use a different form or modify the form.

If you change to the more complex General Purpose Data Entry Form named MNHNL Dynamic 1 and configure it, including checking the Occurrence Images box in the Species section, then you'll get a photo upload box.

Alternatively, if you edit client_helpers/prebuilt_forms/basic1.php and, within the get_form() function, insert a call to the library function data_entry_helper::file_box something like

    $r .= data_entry_helper::file_box(array(
        'table'=>'occurrence_image',
    ));

that should do the trick. Note that this is attaching an image to an occurrence but you can also attach images to samples and locations (and taxa but this would not likely feature in an online recording form) by changing the table parameter.

Look in client_helpers/data_entry_helper.php for the file_box() function to see all of the parameters that you could supply. http://code.google.com/p/indicia/wiki/FileUploadSettings is also relevant.

Regards
Jim Bacon.

3

Re: Supporting uploads

Thanks Jim. I've got it working now.

Just for note, I'm using iform-0.7.1 obtained from the googlecode website but there were a couple of bugs in it. Specifically I needed to change the maxUploadSize variable in addRowToGrid.js from '4M' to a real integer value. I also had to modify $relpath in data_entry_helper.php as the path used was incorrect in my case (we don't install the iform module into /sites/all).

This probably won't be a problem in the future as I notice the 0.7.1 code doesn't match the trunk in google code any more. Should we be using a more recent version of the iform module?

Regards,
Chris.

4

Re: Supporting uploads

Hi Chris

We have a development / test / release cycle that sees changes being made to both client and warehouse code. Version 0.7.1 is the currently released version. Version 0.8.0 is coming soon. From the repository you can obtain the current development version. Because the client and warehouse code are developed together, the development version of the client may not function fully with the current release of the warehouse. You are therefore using the correct version of iForm. However, if you encounter problems,  it can be worth looking at what is changed in the repository as this includes bugfixes.

There have been occasions in the past when we have started a branch of a release in the repository just for bug fixes, not development, but that is not the case at present.

I can see that maxUploadSize has been corrected for the next release. I am less clear about the problem with $relpath as this is calculated from functions in helper_base.php that, from a quick inspection, make no assumptions about the use of Drupal, let alone installation in a particular Drupal folder. Can you elaborate on what problem you found there and what you felt needed changing.

Jim Bacon

5

Re: Supporting uploads

Hi Jim,

Basically the dynamic component which tries to load plupload.flash.swf is passed the $relpath which points to the location on disk, rather then being reformatting as a url.

Specifically on line 1534 changing
$relpath = self::getRootFolder() . self::relative_client_helper_path();
to
$relpath = '/'.drupal_get_path('module', 'iform').'/client_helpers/';

Fixed my issue of incorrectly setting the javascript uploadSettings object.