cancel
Showing results for 
Search instead for 
Did you mean: 

DPM - can't use custom image as submit button?

Hi,

 

I ran across a hitch, the fix of which might help others out...

 

I'm using AuthorizeNetDPM::getCreditCardForm and editing the form in anet_php_sdk/lib/AuthorizeNetDPM.php

 

I wanted to replace the submit button with a custom image, replacing:

 

<input type="submit" value="BUY" class="buy submit"> with

<input type="image" src="/images/submitpayment.png" width="133" height="27" />

 

but I got an error:

Fatal error: Cannot access empty property in <snip>\anet_php_sdk\lib\AuthorizeNetSIM.php on line 37

 

Using an image submit produces x=, and y= fields in the $_POST, the code around line37 strips off the (arbitrary) first 2 characters the field name, expecting 'x_', hence the error.

Giving the submit image a name attribute helped, but I got other errors, presumably because of the extra field data. I had to add an exclusion clause to the function to ignore fields prefixed with my image name, and it *seems* to be going through, in test at least.

 

That's after I corrected the other errors in the php sample code of course! Hope this helps someone...

webaria
Member
3 REPLIES 3

Hey there,

 

Thanks for the heads up and for the fix. I've forwarded your feedback on to our development teams so they can take a look at what you found.

 

Thanks,

 

Michelle

Developer Community Manager

Michelle
All Star

Over a year later and it appears this bug hasn't been fixed yet in the SDK.

 

Here's my recommendation starting with line 34 of AuthorizeNetSIM.php

 

        // Set fields without x_ prefix
        foreach( $_POST as $key => $value ){

            if( substr($key,0, 2) == 'x_' ){
               $name = substr($key, 2);
               $this->$name = $value;
            }
        }

 

 

Just remove the regular submit button and add an image with a bit of Javascript for submitting the form:

 

<a href="" onclick="document.forms.myform.submit(); return false;"><img src="/images/mysubmitbutton.jpg" width="100" height="30" border="0" alt="Submit"></a>

 Change myform to the name of your form.