This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Replace the Submit button with an Image


  1. martinswales
    Member

    Hi I've got the latest Mach Form which I bought because I'm not a developer although I can stumble my way through bits of code.

    Problem is I need to change the submit button to a graphic on a clients form, ive seen bits of posts on this forum but these dont seem to reflect my files as the line numbers etc seem different does anybody have a straight forward guide on how to change the submit button. It would be much appreciated.

    thanks

    Posted 13 years ago #
  2. redityo

    Try to edit "includes/view-functions.php" file and go to around line 1759. You will see these code :

    <input id="saveForm" class="button_text" type="submit" name="submit" value="{$button_text}" />

    then change it to

    <input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="{$button_text}" />

    after that go to around line 2097 and you 'll see this code

    $submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="submit" name="submit" value="'.$lang['submit_button'].'" />';

    then change it to

    $submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="'.$lang['submit_button'].'" />';

    don't forget to change "src" value with your image path. That would change the submit button into an image


    MachForm Support

    Posted 13 years ago #
  3. martinswales
    Member

    great thanks

    Posted 13 years ago #
  4. martinswales
    Member

    That works thanks, my only problem is i have 2 forms which need different buttons any idea how to do that as at the minute they have the same submit button?

    Posted 13 years ago #
  5. redityo

    You can add the conditional to the code. Try to follow these steps:

    1. On the line 1759, you need to change these code

    <input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="{$button_text}" />

    into

    <input id="saveForm" class="button_text" type="image" src="{$img_src}" name="submit" value="{$button_text}" />

    Then go to line 1754 for this code :

    $button_markup =<<<EOT

    and put these code exactly above that line

    switch ($form_id) {
    	case 22 :
    		//form 22
    		$img_src = "images/exec.png";
    		break;
    	case 23 :
    		//form 23
    		$img_src = "images/click_to_add.gif";
    		break;
    
    	default :
    		$img_src = "images/exec.png";
    		break;
    }

    2. For line 2097 , you can add the condition to these code.

    $submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="'.$lang['submit_button'].'" />';

    you can change it into like this

    if ($form->id == 22) {
    	$submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="'.$lang['submit_button'].'" />';
    } elseif ($form->id == 23 ) {
    	$submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="image" src="images/click_to_add.gif" name="submit" value="'.$lang['submit_button'].'" />';
    } else {
    	$submit_button = '<input type="hidden" name="submit" value="1" />'."\n".'<input id="saveForm" class="button_text" type="image" src="images/exec.png" name="submit" value="'.$lang['submit_button'].'" />';
    }

    don't forget to change the form id with yours


    MachForm Support

    Posted 13 years ago #
  6. martinswales
    Member

    Hi I've tried this but it doesn't seem to change the actual image, ive changed the form id but still wont work. Any ideas

    Posted 13 years ago #
  7. redityo

    Hmm it should works..
    is it possible to send me your file. You can send it here :

    customer.service[at]appnitro.com

    I will help you to check it


    MachForm Support

    Posted 13 years ago #
  8. martinswales
    Member

    Great thanks for all your help, much appreciated

    Posted 13 years ago #
  9. Radices
    Member

    Hi Yuniar,

    I'm wanting to change the button text based on the form number. I have spent 3-4 hours trying to modify the example above but cannot get it to work. I can see how it changes based on whether you have a review page and in the end modified the language.php file as a work around.

    Thanks in advance,

    Glenn

    Posted 13 years ago #
  10. yuniar

    Hi Glenn,

    Do you have form review enabled or not? Also, are you using the iframe embed code or the php embed code?

    The code would depends on the above condition.


    MachForm Founder

    Posted 13 years ago #
  11. Radices
    Member

    Hi Yuniar,

    I am using form review but not embeding it in any way.

    Posted 13 years ago #
  12. yuniar

    Sorry for the late reply. I've just replied to your email, let's continue there.


    MachForm Founder

    Posted 13 years ago #

RSS feed for this topic

Reply