Loading ...
Sorry, an error occurred while loading the content.

problem testing smarty form

Expand Messages
  • simian187
    I have not been able to succesfully run the test_smarty_form.php script. I get the form page, but only the title, and header Test for Manuel Lemos PHP form
    Message 1 of 11 , Feb 7, 2005
    • 0 Attachment
      I have not been able to succesfully run the test_smarty_form.php
      script. I get the form page, but only the title, and header "Test
      for Manuel Lemos' PHP form class". The rest of the page is blank.
      At the beginning, there is the following text:
      PageLoad: it was not specified a valid named form element to define
      a function

      I'm not really sure what is wrong, maybe the fetch("form.tpl") is
      not working?

      I'm using the lastest version as well as the latest Smarty: 2.6.7

      Thanks for any help or pointers
      -Marc
    • Manuel Lemos
      Hello, ... I have tested the example with that version of Smarty and it works fine. Usually the error that you mentioned happens when you change the form
      Message 2 of 11 , Feb 7, 2005
      • 0 Attachment
        Hello,

        on 02/07/2005 09:56 PM simian187 said the following:
        > I have not been able to succesfully run the test_smarty_form.php
        > script. I get the form page, but only the title, and header "Test
        > for Manuel Lemos' PHP form class". The rest of the page is blank.
        > At the beginning, there is the following text:
        > PageLoad: it was not specified a valid named form element to define
        > a function
        >
        > I'm not really sure what is wrong, maybe the fetch("form.tpl") is
        > not working?
        >
        > I'm using the lastest version as well as the latest Smarty: 2.6.7

        I have tested the example with that version of Smarty and it works fine.

        Usually the error that you mentioned happens when you change the form
        script and remove or rename the form input that is specified in the call
        to the AddFunction function in the example. That call is necessary to
        give the input focus to a certain input when the page is loaded.

        The default input that gets the focus is the email input. If you changed
        or removed that field, the error above should appear. If that is your
        problem, you can either change the AddFunction call to set the focus to
        some other input of your test form, or just remove the AddFunction call
        and also remove the ONLOAD attribute that calls a Javascript function
        named PageLoad() in the BODY attribute of the page template.

        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/

        PHP Reviews - Reviews of PHP books and other products
        http://www.phpclasses.org/reviews/

        Metastorage - Data object relational mapping layer generator
        http://www.meta-language.net/metastorage.html
      • simian187
        ... header Test ... blank. ... define ... is ... fine. ... form ... the call ... to ... changed ... your ... focus to ... call ... function ... It appears
        Message 3 of 11 , Feb 8, 2005
        • 0 Attachment
          --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@a...> wrote:
          > Hello,
          >
          > on 02/07/2005 09:56 PM simian187 said the following:
          > > I have not been able to succesfully run the test_smarty_form.php
          > > script. I get the form page, but only the title, and
          header "Test
          > > for Manuel Lemos' PHP form class". The rest of the page is
          blank.
          > > At the beginning, there is the following text:
          > > PageLoad: it was not specified a valid named form element to
          define
          > > a function
          > >
          > > I'm not really sure what is wrong, maybe the fetch("form.tpl")
          is
          > > not working?
          > >
          > > I'm using the lastest version as well as the latest Smarty: 2.6.7
          >
          > I have tested the example with that version of Smarty and it works
          fine.
          >
          > Usually the error that you mentioned happens when you change the
          form
          > script and remove or rename the form input that is specified in
          the call
          > to the AddFunction function in the example. That call is necessary
          to
          > give the input focus to a certain input when the page is loaded.
          >
          > The default input that gets the focus is the email input. If you
          changed
          > or removed that field, the error above should appear. If that is
          your
          > problem, you can either change the AddFunction call to set the
          focus to
          > some other input of your test form, or just remove the AddFunction
          call
          > and also remove the ONLOAD attribute that calls a Javascript
          function
          > named PageLoad() in the BODY attribute of the page template.
          >
          > --
          >
          > Regards,
          > Manuel Lemos
          >
          > PHP Classes - Free ready to use OOP components written in PHP
          > http://www.phpclasses.org/
          >
          > PHP Reviews - Reviews of PHP books and other products
          > http://www.phpclasses.org/reviews/
          >
          > Metastorage - Data object relational mapping layer generator
          > http://www.meta-language.net/metastorage.html

          It appears that the smarty_prefilter_form routine is not called in
          this block:

          $smarty->register_prefilter("smarty_prefilter_form");
          $smarty->fetch("form.tpl");
          $smarty->unregister_prefilter("smarty_prefilter_form");

          I put debug output in prefilter.form.php, and found that it is
          loaded properly with require(), but is never called.
          I will have to debug Smarty to find out why fetch() is not
          processing the template.

          I will let you know what I find out.
        • simian187
          ... test_smarty_form.php ... 2.6.7 ... works ... necessary ... AddFunction ... OK nothing wrong with Smarty - but here s where it fails in forms.php: Function
          Message 4 of 11 , Feb 8, 2005
          • 0 Attachment
            --- In forms-dev@yahoogroups.com, "simian187" <mmauger_san@h...>
            wrote:
            >
            > --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@a...> wrote:
            > > Hello,
            > >
            > > on 02/07/2005 09:56 PM simian187 said the following:
            > > > I have not been able to succesfully run the
            test_smarty_form.php
            > > > script. I get the form page, but only the title, and
            > header "Test
            > > > for Manuel Lemos' PHP form class". The rest of the page is
            > blank.
            > > > At the beginning, there is the following text:
            > > > PageLoad: it was not specified a valid named form element to
            > define
            > > > a function
            > > >
            > > > I'm not really sure what is wrong, maybe the fetch("form.tpl")
            > is
            > > > not working?
            > > >
            > > > I'm using the lastest version as well as the latest Smarty:
            2.6.7
            > >
            > > I have tested the example with that version of Smarty and it
            works
            > fine.
            > >
            > > Usually the error that you mentioned happens when you change the
            > form
            > > script and remove or rename the form input that is specified in
            > the call
            > > to the AddFunction function in the example. That call is
            necessary
            > to
            > > give the input focus to a certain input when the page is loaded.
            > >
            > > The default input that gets the focus is the email input. If you
            > changed
            > > or removed that field, the error above should appear. If that is
            > your
            > > problem, you can either change the AddFunction call to set the
            > focus to
            > > some other input of your test form, or just remove the
            AddFunction
            > call
            > > and also remove the ONLOAD attribute that calls a Javascript
            > function
            > > named PageLoad() in the BODY attribute of the page template.
            > >
            > > --
            > >
            > > Regards,
            > > Manuel Lemos
            > >
            > > PHP Classes - Free ready to use OOP components written in PHP
            > > http://www.phpclasses.org/
            > >
            > > PHP Reviews - Reviews of PHP books and other products
            > > http://www.phpclasses.org/reviews/
            > >
            > > Metastorage - Data object relational mapping layer generator
            > > http://www.meta-language.net/metastorage.html
            >
            > It appears that the smarty_prefilter_form routine is not called in
            > this block:
            >
            > $smarty->register_prefilter("smarty_prefilter_form");
            > $smarty->fetch("form.tpl");
            > $smarty->unregister_prefilter("smarty_prefilter_form");
            >
            > I put debug output in prefilter.form.php, and found that it is
            > loaded properly with require(), but is never called.
            > I will have to debug Smarty to find out why fetch() is not
            > processing the template.
            >
            > I will let you know what I find out.

            OK nothing wrong with Smarty - but here's where it fails in
            forms.php:
            Function AddFunction($arguments)

            Called in test_smarty_form.php:
            $subscription->AddFunction(array(
            "Function"=>"PageLoad",
            "Type"=>"focus",
            "Element"=>(count($verify) ? Key
            ($verify) : "email")
            ));


            Here's the output of print_r($this->inputs[$input]);

            Array ( [NAME] => email [ID] => email [ValidateAsEmail] => 1
            [ClientValidate] => 1 [ServerValidate] => 1 [ValidationErrorMessage]
            => It was not specified a valid e-mail address [TYPE] => text
            [MAXLENGTH] => 100 [Capitalization] => lowercase [LABEL] => E-mail
            address [ACCESSKEY] => E [SubForm] => )


            But on line 1096 of forms.php, there is the following if statement:

            if(IsSet($this->inputs[$input]["InputElement"]) &&
            strcmp($this->inputs[$input]["InputElement"],""))


            and if that fails that's where you get the error:
            "it was not specified a valid named form element to define a
            function",$name

            $name being PageLoad.

            So where Does InputElement get set?
          • Manuel Lemos
            Hello, ... The pre-filter is only called when the template is compiled. When you call fetch(), the pre-filter has already been executed. -- Regards, Manuel
            Message 5 of 11 , Feb 8, 2005
            • 0 Attachment
              Hello,

              on 02/08/2005 01:04 PM simian187 said the following:
              > It appears that the smarty_prefilter_form routine is not called in
              > this block:
              >
              > $smarty->register_prefilter("smarty_prefilter_form");
              > $smarty->fetch("form.tpl");
              > $smarty->unregister_prefilter("smarty_prefilter_form");

              The pre-filter is only called when the template is compiled. When you
              call fetch(), the pre-filter has already been executed.

              --

              Regards,
              Manuel Lemos

              PHP Classes - Free ready to use OOP components written in PHP
              http://www.phpclasses.org/

              PHP Reviews - Reviews of PHP books and other products
              http://www.phpclasses.org/reviews/

              Metastorage - Data object relational mapping layer generator
              http://www.meta-language.net/metastorage.html
            • Manuel Lemos
              Hello, ... This means that the input field element specified in the AddFunction call is not present in the form output definition. It seems that either you
              Message 6 of 11 , Feb 8, 2005
              • 0 Attachment
                Hello,

                on 02/08/2005 02:46 PM simian187 said the following:
                > OK nothing wrong with Smarty - but here's where it fails in
                > forms.php:
                > Function AddFunction($arguments)
                >
                > Called in test_smarty_form.php:
                > $subscription->AddFunction(array(
                > "Function"=>"PageLoad",
                > "Type"=>"focus",
                > "Element"=>(count($verify) ? Key
                > ($verify) : "email")
                > ));
                >
                >
                > Here's the output of print_r($this->inputs[$input]);
                >
                > Array ( [NAME] => email [ID] => email [ValidateAsEmail] => 1
                > [ClientValidate] => 1 [ServerValidate] => 1 [ValidationErrorMessage]
                > => It was not specified a valid e-mail address [TYPE] => text
                > [MAXLENGTH] => 100 [Capitalization] => lowercase [LABEL] => E-mail
                > address [ACCESSKEY] => E [SubForm] => )
                >
                >
                > But on line 1096 of forms.php, there is the following if statement:
                >
                > if(IsSet($this->inputs[$input]["InputElement"]) &&
                > strcmp($this->inputs[$input]["InputElement"],""))
                >
                >
                > and if that fails that's where you get the error:
                > "it was not specified a valid named form element to define a
                > function",$name
                >
                > $name being PageLoad.
                >
                > So where Does InputElement get set?

                This means that the input field element specified in the AddFunction
                call is not present in the form output definition. It seems that either
                you have not added the specified input field to the form, or you are
                using a different or changed template for the form body that does not
                contain in the specified input field, which by default is email.

                Have you changed the form input definitiions, or changed the example
                templates, or you are using different templates?

                --

                Regards,
                Manuel Lemos

                PHP Classes - Free ready to use OOP components written in PHP
                http://www.phpclasses.org/

                PHP Reviews - Reviews of PHP books and other products
                http://www.phpclasses.org/reviews/

                Metastorage - Data object relational mapping layer generator
                http://www.meta-language.net/metastorage.html
              • counter intelligence
                Hello Manuel, No I have not changed the templates (form.tpl, header.tpl, footer.tpl, formerror.tpl). The email section of the template looks like this:
                Message 7 of 11 , Feb 9, 2005
                • 0 Attachment
                  Hello Manuel,

                  No I have not changed the templates (form.tpl, header.tpl, footer.tpl,
                  formerror.tpl).
                  The email section of the template looks like this:

                  <tr>
                  <th align="right">{label for="email"}:</th>
                  <td>{input name="email"}</td>
                  {if isset($verify.email)}<td>{$mark}</td>
                  {/if}
                  </tr>

                  >From: Manuel Lemos <mlemos@...>
                  >Reply-To: forms-dev@yahoogroups.com
                  >To: forms-dev@yahoogroups.com
                  >Subject: Re: [forms-dev] Re: problem testing smarty form
                  >Date: Tue, 08 Feb 2005 21:55:30 -0200
                  >
                  >Hello,
                  >
                  >on 02/08/2005 02:46 PM simian187 said the following:
                  > > OK nothing wrong with Smarty - but here's where it fails in
                  > > forms.php:
                  > > Function AddFunction($arguments)
                  > >
                  > > Called in test_smarty_form.php:
                  > > $subscription->AddFunction(array(
                  > > "Function"=>"PageLoad",
                  > > "Type"=>"focus",
                  > > "Element"=>(count($verify) ? Key
                  > > ($verify) : "email")
                  > > ));
                  > >
                  > >
                  > > Here's the output of print_r($this->inputs[$input]);
                  > >
                  > > Array ( [NAME] => email [ID] => email [ValidateAsEmail] => 1
                  > > [ClientValidate] => 1 [ServerValidate] => 1 [ValidationErrorMessage]
                  > > => It was not specified a valid e-mail address [TYPE] => text
                  > > [MAXLENGTH] => 100 [Capitalization] => lowercase [LABEL] => E-mail
                  > > address [ACCESSKEY] => E [SubForm] => )
                  > >
                  > >
                  > > But on line 1096 of forms.php, there is the following if statement:
                  > >
                  > > if(IsSet($this->inputs[$input]["InputElement"]) &&
                  > > strcmp($this->inputs[$input]["InputElement"],""))
                  > >
                  > >
                  > > and if that fails that's where you get the error:
                  > > "it was not specified a valid named form element to define a
                  > > function",$name
                  > >
                  > > $name being PageLoad.
                  > >
                  > > So where Does InputElement get set?
                  >
                  >This means that the input field element specified in the AddFunction
                  >call is not present in the form output definition. It seems that either
                  >you have not added the specified input field to the form, or you are
                  >using a different or changed template for the form body that does not
                  >contain in the specified input field, which by default is email.
                  >
                  >Have you changed the form input definitiions, or changed the example
                  >templates, or you are using different templates?
                  >
                  >--
                  >
                  >Regards,
                  >Manuel Lemos
                  >
                  >PHP Classes - Free ready to use OOP components written in PHP
                  >http://www.phpclasses.org/
                  >
                  >PHP Reviews - Reviews of PHP books and other products
                  >http://www.phpclasses.org/reviews/
                  >
                  >Metastorage - Data object relational mapping layer generator
                  >http://www.meta-language.net/metastorage.html
                • Manuel Lemos
                  Hello, ... It is hard to tell without further examination. If the input field is not added to the form output when the AddFunction is called and you have not
                  Message 8 of 11 , Feb 9, 2005
                  • 0 Attachment
                    Hello,

                    on 02/09/2005 04:40 PM counter intelligence said the following:
                    > No I have not changed the templates (form.tpl, header.tpl, footer.tpl,
                    > formerror.tpl).

                    It is hard to tell without further examination. If the input field is
                    not added to the form output when the AddFunction is called and you have
                    not changed the original example files, I suspect that for some reason
                    Smarty is not successfully processing the templates. It may be due to
                    permissions of the template files.

                    What you can do to check whether the form output was composed properly
                    is to output the form object parts variable like this:
                    var_dump($subscription->parts);

                    --

                    Regards,
                    Manuel Lemos

                    PHP Classes - Free ready to use OOP components written in PHP
                    http://www.phpclasses.org/

                    PHP Reviews - Reviews of PHP books and other products
                    http://www.phpclasses.org/reviews/

                    Metastorage - Data object relational mapping layer generator
                    http://www.meta-language.net/metastorage.html
                  • simian187
                    ... footer.tpl, ... have ... It turns out that it was a permissions problem. The template files were not readable by apache. D oh! Thanks for taking the time
                    Message 9 of 11 , Feb 9, 2005
                    • 0 Attachment
                      --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@a...> wrote:
                      > Hello,
                      >
                      > on 02/09/2005 04:40 PM counter intelligence said the following:
                      > > No I have not changed the templates (form.tpl, header.tpl,
                      footer.tpl,
                      > > formerror.tpl).
                      >
                      > It is hard to tell without further examination. If the input field is
                      > not added to the form output when the AddFunction is called and you
                      have
                      > not changed the original example files, I suspect that for some reason
                      > Smarty is not successfully processing the templates. It may be due to
                      > permissions of the template files.
                      >
                      > What you can do to check whether the form output was composed properly
                      > is to output the form object parts variable like this:
                      > var_dump($subscription->parts);
                      >
                      > --
                      >
                      > Regards,
                      > Manuel Lemos
                      >
                      > PHP Classes - Free ready to use OOP components written in PHP
                      > http://www.phpclasses.org/
                      >
                      > PHP Reviews - Reviews of PHP books and other products
                      > http://www.phpclasses.org/reviews/
                      >
                      > Metastorage - Data object relational mapping layer generator
                      > http://www.meta-language.net/metastorage.html

                      It turns out that it was a permissions problem. The template files
                      were not readable by apache. D'oh!
                      Thanks for taking the time to help me with this. Now I can finally
                      start using your software!

                      Regards,
                      Marc M
                    • operationsengineer1@yahoo.com
                      before allowing data to interact with a database, one should prepare the data to make sure it will be stored in the database correctly and prevent malicious
                      Message 10 of 11 , Feb 10, 2005
                      • 0 Attachment
                        before allowing data to interact with a database, one
                        should prepare the data to make sure it will be stored
                        in the database correctly and prevent malicious
                        behavior.

                        in php, there are functions like

                        addslashes()
                        htmlspecialchars()
                        htmlentities()

                        help address these issues.

                        in adodb, qstr() implements a method that makes
                        addslashes() unnecessary.

                        does manuel's form class have any functions that
                        handle this type of data manipulation or should i rely
                        on php and adodb to do this?

                        tia...





                        __________________________________
                        Do you Yahoo!?
                        Yahoo! Mail - now with 250MB free storage. Learn more.
                        http://info.mail.yahoo.com/mail_250
                      • Manuel Lemos
                        Hello, ... For presenting values in the forms, the forms class already uses HtmlEntities() to output HTML tag attribute values and data. Escaping text strings
                        Message 11 of 11 , Feb 12, 2005
                        • 0 Attachment
                          Hello,

                          on 02/10/2005 06:51 PM operationsengineer1@... said the following:
                          >
                          > before allowing data to interact with a database, one
                          > should prepare the data to make sure it will be stored
                          > in the database correctly and prevent malicious
                          > behavior.
                          >
                          > in php, there are functions like
                          >
                          > addslashes()
                          > htmlspecialchars()
                          > htmlentities()
                          >
                          > help address these issues.
                          >
                          > in adodb, qstr() implements a method that makes
                          > addslashes() unnecessary.
                          >
                          > does manuel's form class have any functions that
                          > handle this type of data manipulation or should i rely
                          > on php and adodb to do this?

                          For presenting values in the forms, the forms class already uses
                          HtmlEntities() to output HTML tag attribute values and data.

                          Escaping text strings for use in database queries is specific to each
                          type of database. AddSlashes is not the correct solution for all
                          databases for escaping text strings from values submited with the forms.

                          I do not use ADODB. I use Metabase. It has a function named
                          GetTextFieldValue for properly formatting and escaping text values if
                          necessary. For other types of database fields there are other functions.
                          It can also use prepared queries, which implicitly escape any type of
                          values when needed.

                          Please read Metabase documentation sections on Data type conversion and
                          Prepared queries if you want to know more about this:

                          http://www.phpclasses.org/metabase

                          If you use ADODb, that function may be appropriate for escaping text
                          values. I don't know about other datatypes.



                          --

                          Regards,
                          Manuel Lemos

                          PHP Classes - Free ready to use OOP components written in PHP
                          http://www.phpclasses.org/

                          PHP Reviews - Reviews of PHP books and other products
                          http://www.phpclasses.org/reviews/

                          Metastorage - Data object relational mapping layer generator
                          http://www.meta-language.net/metastorage.html
                        Your message has been successfully submitted and would be delivered to recipients shortly.