Using 'image' input types in formslib

Using 'image' input types in formslib

by Mike Churchward -
Number of replies: 1
Picture of Core developers Picture of Plugin developers Picture of Testers
I'm trying to re-create the standard edit type icons (edit, delete, move, etc.) using formslib. I tried using an 'image' element for this, but something seems to prevent information getting generated.

I have, for example, this statement:
$mform->addElement('image', 'field1', '[image source]);

The form shows the icon okay, and clicking on it generates a submit to the form, but there is no information in the formdata to indicate that the image was the input clicked.

Anyone know if this can work?
Average of ratings: -
In reply to Mike Churchward

Re: Using 'image' input types in formslib

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers
What I've found...

Quickform doesn't return values for 'image', 'reset', 'button' or 'file' input types intentionally. 'formslib' uses the 'exportValue' method to get data from a submitted form. Since Quickform doesn't return values for an 'image' input type, 'formslib' doesn't return any information for the 'image' input.

I'm not sure if there is another way to get data from an 'image' input using Quickform.

But, I have made this work by calling 'data_submitted' first and looking for the 'image' input data - it is returned in standard form data; just not in formslib. Then, I just add the image input data to the formslib data.

Not ideal, but it works.