The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Using <input type="image" - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5)
+--- Thread: Using <input type="image" (/showthread.php?tid=1678)



Using <input type="image" - cynix666 - Oct 7th, 2011

Ok, new to Forms Tools (2.1.2) have installed and successfully built API and simple POST forms up to this point. I am now trying to use an image as the submit button like this:

Code:
<input type="image" value="submit" src="/i/hm_cta_bot.gif" name="mrcontactsubmit" alt="Get Started" />

Everything else is the same as has been successful before. But, using the image submit, I get a page refresh and all values are lost. FT cannot initialize the form and data is not being submitted. Then, if I swap out the image for a regular button it seems to work great again.

It seems to me that FT just does not want to take an image for a Submit button. Is this the case or is there special syntax that should be used when trying to use an image?

Running out of ideas, any help/insight is very much appreciated!

-Aaron




RE: Using <input type="image" - Ben - Oct 10th, 2011

Hey Aaron,

MAN, I must document this! This has tripped up lots of people.

Image submit buttons are handled differently in the HTML spec. Simple submit buttons sent along a name-value pair corresponding to the button that was clicked; image buttons don't: they pass along some X & Y coordinates with the submit name attribute as the prefix. I'm not entirely sure this is consistent across browsers, either...

Anyway, to use a image submit button in an API form (POST forms are fine), you need to let the ft_api_process_form() function know that the form has been submitted by specifying a different form field - one that you know will always be included on the POST request.

So, add this to your form:

Code:
<input type="hidden" name="is_submitted" value="1" />

Then, in your API code at the top of the page, use the "is_submitted" hidden field as the fake submit button.

PHP Code:
$params = array(
 ... 
 
"submit_button" => "is_submitted",
  ...
); 

In retrospect, the "submit_button" key wasn't named very well: I didn't take into account this situation with image submit buttons. I should have called it something like "form_submit_includes_key" or something more generic. Oh well. In the code, all it's doing is checking to confirm that the POST request includes that name-value pair. If it IS, it processes the form. Otherwise it ignores it.

Anyway, hope this helps! Let me know if you run into any other problems. Smile

- Ben