douwang6635 2019-02-11 11:13
浏览 120
已采纳

Ninja Forms自定义PDF模板返回错误

I have created a custom pdf template for ninja forms pdf submission add on from the example provided here: https://www.speakinginbytes.com/2014/11/customizing-ninja-forms-pdf-submissions/

So I placed a new pdf.php and pdf.css file inside a folder named "ninja-forms-pdf-submissions" in my child theme.

This custom pdf template used to work perfectly before but now it's returning an error that says

Uncaught TypeError: Cannot read property 'fields' of undefined
at n.submitErrors (front-end.js?ver=3.4.3:1)
at _ (backbone.min.js?ver=1.2.3:1)
at m (backbone.min.js?ver=1.2.3:1)
at f (backbone.min.js?ver=1.2.3:1)
at u.Channel.u.trigger (backbone.min.js?ver=1.2.3:1)
at Object.error (front-end.js?ver=3.4.3:3)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as rejectWith] (jquery.js?ver=1.12.4:2)
at y (jquery.js?ver=1.12.4:4)
at XMLHttpRequest.c (jquery.js?ver=1.12.4:4)

Below is the template I created.

<?php
/**
 * PDF Included With Form Submission
 *
 * @author      Patrick Rauland
 * @version     1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

?>
<html>
<head>
    <link type="text/css" href="<?php echo $css_path; ?>" rel="stylesheet" />
    <link type="text/css" href="../../../themes/swu-child-2/ninja-forms-pdf-submissions/pdf.css" rel="stylesheet"/>
</head>
<body>
    <header>
        <img src="../../../uploads/2017/09/swu-logo-2.png"/>
    </header>
    <div id="main">
        <h1><?php echo $title; ?> (Report Answers)</h1>
        <p>Hi <?php echo $fields[317]['value'];?> <?php echo $fields[318]['value'];?>!</p>
        <p>Thank you for your completing our financial success health check. At SWU Group, we are here to provide stewardship with regards to all aspects of your financial life and success. In this report, you will see the areas in which you are doing well in your financial life and areas in which you can improve on. The SWU Group family office is here to help you both maintain the areas of your financial life where you are doing well and provide guidance and advice in the areas you need improvement on to achieve your financial success.</p>
        <p>Please note that this report is not financial product advice and is intended to provide information only.  It does not take into account your investment objectives, financial situation or needs. You should assess whether the information is appropriate for you and consider talking to a financial adviser before making an investment decision. The information is taken from sources which are believed to be accurate but the SWU Group and its associated companies accepts no liability of any kind to any person who relies on the information contained in this report.</p>
        <p>If you have any questions, please free to contact us:</p>
        <p>Phone: (02) 9211 0228</p>
        <p>Email:<a href="mailto:financialsuccess@simonwu.com.au">financialsuccess@simonwu.com.au</a></p>
    </div>

    <?php //echo $table; ?>

    <?php
        $defsuccscore = $fields[309]['value'];
        $debtstratscore = $fields[310]['value'];
        $budgetscore = $fields[311]['value'];
        $assetprotscore = $fields[312]['value'];
        $estateplanscore = $fields[313]['value'];
        $supannuationscore = $fields[314]['value'];
        $selfmanagedsupfundscore = $fields[391]['value'];
        $investmentscore = $fields[398]['value'];

        //echo $defsuccscore;

    echo "<h2>Definition of success</h2>";

        if ($defsuccscore >= 7.5) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Having clear financial goals is very important for you to focus on, and it seems that you have these in place. That way, you know where you want to be and when, so well done! Whether it be a holiday once a year, saving for another investment property or simply saving aggressively to pay off your mortgage, the goal must be clear, measureable and timely. To ensure you are always motivated to achieve your goals, set some short, medium and long term ones. If you are 40 years old or above, one of the biggest goals you must have on your list is your retirement savings and how to maximise this through superannuation.</p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NEEDS IMPROVEMENT</h3><p>This is an area you need to improve on. Goals are key to financial success. You need to define what success means to you and then attach goals to that definition. Whether it be a holiday once a year, saving for another investment property or simply saving aggressively to pay off your mortgage, the goal must be clear, measureable and timely. To ensure you are always motivated to achieve your goals, set some short, medium and long term ones. If you are 40 years old or above, one of the biggest goals you must have on your list is your retirement savings. Seeking out the professional advice of a financial adviser from the SWU Group can assist you in defining your financial success and goals to achieve it.</p>';
        }

        echo "<h2>Debt Strategies</h2>";

        if ($debtstratscore >= 7.5) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Well done, you seem to have a good understanding of how to manage your debt levels. Remember the importance of reducing your non-deductible debt first because this has the greatest impact to your after tax cash flow. Linking this back to financial goals, having a clearly defined timeline as to how you are going to pay down non-deductible debt is a great motivator to achieving financial success. With regards to your deductible debt, note that while it can be tax deductible, it still impacts your cash flow each month and that you won’t receive the benefits of this until you lodge your tax return after the end of the financial year (30 June each year). Deductible debt should also be continuously monitored and ensure you can afford to pay both principal and interest over the long term, not just the interest component.</p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NEEDS IMPROVEMENT</h3><p>Debt can be both a good and bad thing and you may need help with managing it. If the debt is non-deductible which generally includes the mortgage of your principal place of residence (home) this is the type of debt you want to prioritise in paying off. Deductible debt are those which are used mainly for investment purposes (investment property, margin loans, and home equity loans). Interest payments can be tax deductible meaning that your after tax interest cost is generally less than what you actually pay each month. When considering taking on tax deductible debt, ensure you calculate your after tax interest cost vs your potential investment return to see if it is worthwhile to make the investment. Note that while this type of debt can be tax deductible, it still impacts on your cash flow each month and that you won’t receive the benefits of this until you lodge your tax return after the end of the financial year (30 June each year). You should make an appointment to see a financial adviser at the SWU Group to see if you have your debt under control and if there are ways to structure it to maximise tax efficiencies.</p>';
        }

        echo "<h2>Budgeting</h2>";

        if ($budgetscore > 10) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Budgeting is one of the most important elements of a long term financial plan. Without a budget, you don’t know if you are living within your means and if you can afford other things such as holidays, investments or other big purchases. It’s good to see that you are doing well in this area and that you have surplus income meaning your income is greater than your expenses. Budgeting is also good to ensure you are keeping track of how much you are saving and linking this back to your financial goals. Remember – every little bit you save in the short term, makes a big difference in the long term! Are you maximising your savings? If you would like to find out how to get the most out of your savings, contact us for a no obligation consultation.</p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NEEDS IMPROVEMENT</h3><p>One of the first parts to any prudent financial plan is setting up a proper budget. This is an area which requires your attention. Budgeting allows you to clearly calculate if you are living within your means and if you can afford other things such as holidays, investments or other big purchases. One of the biggest problems we see is that many people have more expenses than income each month and end up taking on credit card debt which in the long term is clearly not sustainable. Even if you have surplus cash flow each month, are you maximising what you can do with it? You should make an appointment to see a financial adviser at the SWU Group to see how we can help you tailor a budget to suit your needs and assist you in achieving your financial success.</p>';
        }

        echo "<h2>Asset Protection</h2>";

        if ($assetprotscore > 20) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Asset protection which relates to protecting yourself through insurance is a key driver to financial success, especially later in life and more importantly in retirement. This is an area which you seemed to have adequately put in place. You still need to continuously review your current situation just like your investments to ensure what you have in place is still appropriate. This could mean that you may not have enough and need to increase the level of cover, or your needs may have decreased and by decreasing the sums insured, you could reduce the annual premiums which need to be paid. The way you could calculate your needs varies depending on how much debt you have as well as your annual expenses both of yourself and your family. Have you considered putting in place insurances to cover the partner in the family who does not work? Make an appointment to see one of our specialist financial advisers to see if this could increase your families ongoing asset protection needs.</p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NOT SATISFACTORY</h3><p>Asset protection which relates to protecting yourself through insurance is a key driver to financial success, especially later in life and more importantly in retirement. This is an area which you require some improvement and review. Do you protect your car through insurance? Do you protect your home through insurance? Why? It\'s not because you hope that you will one day will have to claim on it, but if you do have an accident or a storm damaging your home, you know you don’t need to draw on your savings to rectify the damage. This applies the same for life and TPD (Total and Permanent Disablement), Income Protection and Trauma. The first and most crucial step is to calculate what your required cover should be and this will require the assistance of a good financial adviser. Furthermore, have you considered putting in place insurances to cover the partner in the family who does not work? Please contact us at the SWU Group to make a no obligation appointment to discuss how we can provide peace of mind to you and your loved ones.</p>';
        }

        echo "<h2>Estate Planning</h2>";

        if ($estateplanscore > 10) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Congratulations – it seems that you have most, if not all of your estate planning arrangements in place. No matter how you achieve your financial success, if you finally have assets leftover when you pass away, you would no doubt want to achieve two things. First and foremost – leave monies to your loved ones and secondly to reduce any disputes that could arise when estates are distributed to beneficiaries. Remember that even though you currently have estate planning arrangements in place, your circumstances will change which may mean that you need to update your arrangements. Also consider how much you paid to get your estate planning in place because as the saying goes - it is very true that you pay for what you get. Post office wills for example while cost effective, can contain many risks which without proper legal advice which in turn could risk your family’s financial future. Furthermore, have you structured your future estate in a way that is tax effective when it arrives in the hands of your beneficiaries? We are happy to review your estate plan as part of an initial consultation at the SWU Group. <a href="#">Click here to see the range of estate planning services we can provide</a></p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NOT SATISFACTORY</h3><p>Most people never consider estate planning as one component of achieving financial success but it most certainly is. It appears that you do need to address this area as it could be improved. The key point here is that no matter how you achieve your financial success, if you finally have assets leftover when you pass away, you would no doubt want to achieve two things. First and foremost – leave monies to your loved ones and secondly to reduce any disputes that can arise when estates are distributed to beneficiaries. While cost is always a consideration in putting an estate plan in place, note that if an effective plan is enacted, this will reduce dispute costs down the track. Short term cost for long term gain! We at the SWU Group have a pain free, effective solution for estate planning which will give you the peace of mind for you and your loved ones. <a hre="#">Click here to see the range of estate planning services we can provide</a></p>';
        }

        echo "<h2>Superannuation</h2>";

        if ($supannuationscore > 10) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>When asking the public what you have in place for your retirement most will answer with their superannuation. While retirement may be still a while away for you, it is good that you seem to be on top of things in this area. It’s great to see that you understand the power of consolidating your super into one account to potentially reduce overall fees. While structurally you are sound, do you effectively manage the investments within your superannuation? Are you taking on too much risk where you are increasing sequential risk, or taking on too little risk where you may not achieve your ultimate financial goal? As part of your initial consultation, we would review both the structure of your superannuation as well as the investments that form part of it. As superannuation law continues to change and evolve from year to year, we can help ensure you are executing the most tax effective strategy in place based upon your circumstances in managing your key retirement asset. We would love to assist you in achieving your financial success! <a href="#">Click here to see the range of financial planning services we can provide and our investment philosophy</a></p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>NOT SATISFACTORY</h3><p>Effective management of your superannuation will be one of key elements to financial success. While retirement may be still a while away for you, it is important that you get on top of it as early as possible. The key reason for this, is that the earlier you put your super on the right track, the better off you could be in retirement. We see too many clients come to us just before they retire, and this is simply too late as they may not be able to contribute all the assets they want  into superannuation, or the strategy to most effectively manage their super would take at least 3-5 years before it is complete. Furthermore, do you know where you are now, and where you want to be when you retire? Given that superannuation law continuously changes and evolves, you should take up an ongoing advice arrangement with a trusted financial adviser to ensure that you are making the most of contribution strategies and investing your hard earned monies in the most appropriate way possible which is in line with your values as well as taking on a level of risk that you are comfortable with. Feel free to contact us at the SWU Group to arrange your initial no obligation consultation. <a href="#">Click here to see the range of financial planning services we can provide and our investment philosophy</a></p>';
        }

        echo "<h2>Self-Managed Super Funds</h2>";

        if ($selfmanagedsupfundscore >= 16) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Self-Managed Super Funds (SMSFs) are one of the most complex structures used for investment purposes and if used correctly and appropriately it can be very effective. From a legal perspective, there are many traps which could lead your SMSF to become non-compliant which could lead it being charged the highest marginal tax possible. This is clearly an undesirable outcome, so it is good to see that you have a current trust deed, a well-documented investment strategy and understand how much it costs you per year to run the fund both from an investment advice perspective as well as accounting. It is important to regularly review your trust deed and investment strategy to ensure it is both appropriate for your needs as well as legally compliant. If you would like these documents reviewed, please feel free to contact us for a no obligation appointment.</p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>UNSATISFACTORY</h3><p>Self-Managed Super Funds (SMSFs) are one of the most complex structures used for investment purposes and if used correctly and appropriately it can be very effective. It must also be made very clear that because of its complexity, many of the regulations and laws which govern SMSFs are often breached leading to the potential of the fund being classed as non-compliant and could face heavy penalties including paying the highest marginal tax rate. We have only highlighted a few elements here including ensuring a current trust deed is in place, a well-documented investment strategy as well as understanding the costs of running your fund from year to year. Given there is at least one area where you either have overlooked or require assistance with, it is imperative that you contact your financial adviser and/or accountant for a review of your fund and personal circumstances. The SWU Group is also here to help, so please contact us for a no obligation review of your funds affairs.</p>';
        }

        echo "<h2>Investments</h2>";

        if ($investmentscore > 30) {
            echo '<img src="../../../uploads/2018/01/check.png"/><br/><h3>SATISFACTORY</h3><p>Fantastic! You seem to be managing your investments reasonably well. It is very important to always find better ways of utilizing excess disposable income that is matched to your level of risk tolerance. Solely relying on your own home and superannuation is not a wise long term strategy to achieving your financial success. If you have a diversified investment portfolio, it is very important for you to review the portfolio regularly, whether it be shares, bonds, property or a combination of all of them. As markets change, so will the value of your investments along with its risk factors. One way to keep you on track and motivated with your investments and returns, is to set yourself lifestyle goals with associated timeframes. Always remember that with any investment, will come with associated level of risk, so it is wise to ensure that both sides are balanced out so that you can sleep easy! </p>';
        }
        else {
            echo '<img src="../../../uploads/2018/01/cross.png"/><br/><h3>UNSATISFACTORY</h3><p>An investment portfolio that doesn’t include your home and superannuation is key to long term financial success. If you have completed a good budget (refer to earlier section), then you will be able to calculate any disposable income you may have that could go towards an investment portfolio. When you consider building an investment portfolio, you need to evaluate the level of risk you are willing to take on, and then to build a portfolio based upon that risk. This is only the beginning of the journey. Many believe in a set and forget strategy whereby once they invest, then they just leave it to grow – this is certainly not a wise path to go down. Investment markets change, risks can rise and fall, so you must ensure you regularly review your investments to ensure they are on track and that they have a reasonable probability of reaching your desired lifestyle goals. If you would like assistance in building your investment portfolio to achieve your financial success, feel free to make an appointment to see one of our financial advisers for a professional review of your circumstances.</p>';
        }

    ?>

</body>
</html>

I've been struggling to find the error now as it used to work before from old versions of the PDF submission add on.

Any help or advice on the custom template I created will greatly help.

Thank you!

  • 写回答

1条回答 默认 最新

  • doukuilian8365 2019-03-06 05:59
    关注

    As per their support group's advise, removing white spaces and extra line breaks on the html structure fixed the issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题