Fork me on GitHub

passing scalar values to templates?  Bottom

  • Hey all this may be a stupid question, but for the life of me I am not real sure how to do this. Ok so I have a very simple test I want to run here is my PHP code thus far:

    Code

    function pnChange_admin_new()
    {
        if (!pnSecAuthAction(0, 'pnChange::', '::', ACCESS_ADD)) {
            return pnVarPrepHTMLDisplay(_MODULENOAUTH);
        }

        $pnRender =& new pnRender('pnChange');

        $pnRender->caching = false;

        if (pnUserLoggedIn()) {
           $name = pnUserGetVar('uname');
        }


        return $pnRender->fetch('pnChange_test_java.htm');
    }


    And here is my template:

    Code

    <!--[include file="pnChange_admin_menu.htm"]-->
    <br /><br />
    <div class="pn-title"><!--[pnml name="_pnChangeADD"]--></div><br /><br />
    <!--[include file="javascripts/read_file"]-->


    <form name="formPicker" action="<!--[pnmodurl modname="pnChange" func="create"]-->" method="post" enctype="application/x-www-form-urlencoded">

    <div>
        <input type="hidden" name="authid" value="<!--[pnsecgenauthkey module="pnChange"]-->" />
        <table border="1" cellpadding="5" cellspacing="1"><tbody>
        <script src="modules/pnChange/pntemplates/javascripts/js_functions.js"></script>
        <input type="hidden" name="stepCount" value="0"/>
        <input type="hidden" name="descCount" value="0"/>

          <tr>
            <td>Change Requestor<br /><input name="requestor" value="<!--[$name|pnvarprepfordisplay]-->"></td>
          </tr>
          <tr>
            <td>Change Management Title<br /><input name="cm_name"></td>
          </tr>
          <tr>
            <td>Description<br /><textarea name="description">Enter a short description...</textarea><br /><br />
                <span id="writeroot2"></span>
                <input type="button" value="Add" onClick="moreDesc( )" />
                <input type="button" value="Remove" style="font-size: 10px" onClick="lessDesc( )" />
            </td>
          </tr>
          <tr>
            <td>Change Step<br /><textarea name="changeStep">Enter change step..</textarea><br /><br />
                <span id="writeroot1"></span>
                <input type="button" value="Add a step" onClick="moreFields( )" />
                <input type="button" value="Remove last step" style="font-size: 10px" onClick="lessFields( )" />
            </td>
          </tr>
          <tr>
            <td><input name=startDate type=text value="" maxlength=10 size=10 onFocus=this.blur()>
                <a href="javascript:void( window.open( 'modules/pnChange/pntemplates/calendar.html?startDate', '', 'width=200,
                 height=210,top=120,left=120' ))"
    ><img src='modules/pnChange/pntemplates/calendar.gif' border=0></a>
            </td>
           </tr>
      <input type="submit" value="Send form" />
         </table>
    </div>
    </form>


    As you can see above I want to pass the vlue I get returned in $name to the form element "requestor" but this is not working right now can anyone show me how to accomplish this please.


    Thanks
    -SUNADMN
  • You forgot to assign the value to the template...


    Code

    $pnRender->Assign('name', $name);

        return $pnRender->fetch('pnChange_test_java.htm');


    before the fetch...
  • doh!!!! See I knew I forgot something stupid thanks.



    -SUNADMN

This list is based on users active over the last 60 minutes.