#1297 new
BJ Kline

Print form and submit to database at the same time

Reported by BJ Kline | June 13th, 2015 @ 12:43 PM

Is there a way I can have the user print the data they've entered into a form and at the same time, save that data to the database?

Comments and changes to this ticket

  • BJ Kline

    BJ Kline June 15th, 2015 @ 05:29 PM

    "We DO provide a view AFTER the user clicks on the 'Submit' button which details all the form entries...this is also the same 'view' an admin can bring up later"

    This is what I want to print. My client doesn't want to go to online ordering yet. So what they've done in the past is have a simple HTML form, but instead of submitting it to a database or email recipient, the end user prints it off and writes their CC info on the printed page and snail mails it to my client.

    I think I need to add an onsubmit to framework/modules/forms/views/forms/confirm_data.tpl line #48 to make this happen?

  • BJ Kline

    BJ Kline June 17th, 2015 @ 02:34 PM

    I tried changing line 48 to this:

    {form onclick="window.print();" action=submit_data}

    But it doesn't bring up the print dialog, the onclick is completely ignored.

  • BJ Kline

    BJ Kline June 17th, 2015 @ 06:50 PM

    I should be able to use that and then create a print stylesheet to only display what I want have the user print.

  • BJ Kline

    BJ Kline June 18th, 2015 @ 12:45 PM

    That code, along with my print style sheet work as long as a user is logged into the site. If not logged in, the print dialog doesn't appear, the form just gets submitted. The page the form is on is set to Public and Active.

    Here is my print stylesheet

    @media print {
        body {
                font-size: 12pt;
                color: #000000;
            }
        #main-menu, #sidebar { 
                display: none;
            }
            
        a.triggerlogin {
                display: none;
            }
        #main { 
                width:100%;
            }
        .print {
                display: block;
                }
        
        .col-xs-6 {
                width: 100%;
                }
        a[href]:after {
        content: none !important;
      }     
        }
    
  • BJ Kline

    BJ Kline June 18th, 2015 @ 06:25 PM

    Adding an id fixed it.

    Here is the working code.

        {form action=submit_data id="orderconf"}
            {foreach from=$postdata item=data key=name}
                {control type=hidden name=$name value=$data}
            {/foreach}
            {control type=antispam}
            {control type=buttongroup submit="Submit Form"|gettext cancel="Change Responses"|gettext}
        {/form}
        
        {script unique=confirm jquery=1}
    {literal}
        $(document).ready(function(){
            $('#orderconf').on('submit', function(e){
                window.print();
            });
        });
    {/literal}
    {/script}
    

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Bug Tracker for Exponent CMS

Shared Ticket Bins

People watching this ticket

Pages