Hi Monks!
Using CGI::Application and I am trying to have an IF inside of the "tml_loop" and its giving me this error:
There has been an error: HTML::Template : Attempt to set nonexistent +parameter 'test' - this parameter name doesn't match any declarations + in the template file : (die_on_bad_params => 1)
I am trying to only show the buttons option if this sub named my_calls sets the value of "test" to true or "1". I dont understand why I am getting the error since I have the <TMPL_IF NAME="test"> tag in the .tmpl file. Could it be that the data coming from the database to populate the "data" tag loop is not yet ready?
The sample part of the Perl file
# temp.pl ... sub my_calls { my $self = shift; my $q = $self->query; my $name = $q->param('name'); my $sql = "select * from my_taable where name = ?"; my $alldata = $self->_get_data($sql, $name); my $template = $self->load_tmpl('mytemp.tmpl'); $template->param('data', $alldata ); $template->param('test' => 1); return $template->output(); } ...
And the portion of the .tmpl file
# mytemp.tmpl ... <form action="" method="post"> <tmpl_loop name=data> <tr> <td align="center"> <input type="checkbox" class="checkbox" name="confirm" value +="n" <tmpl_var name=checked>>&nbsp; </td> <td align="center"> <span id="id_<tmpl_var name=order>"> <tmpl_var name=number> </ +span> </td> <TMPL_IF NAME="test"> <table border="1" width="170" cellspacing="0" cellpadding="0"> <tr> <td> <input name="btnSave_<tmpl_var name=id>" type="button" + value="Save" id="btnSave_<tmpl_var name=id>""> <input name="btnEdit_<tmpl_var name=id>" type="button" + value="Edit" id="btnEdit_<tmpl_var name=id>""> <input name="btnDelete_<tmpl_var name=id>" type="button" + value="Delete" id="btnDelete_<tmpl_var name=id>""> </td> </tr> </table> </TMPL_IF> </td> </tr> </tmpl_loop> </form> ...

In reply to IF in a loop using HTML::Template by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.