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

Custom input validation - error messages - ErrorMessagePrefix showing twice

Expand Messages
  • fen.strat
    Thanks Manuel for the latest update of the class. I noticed a particular bug fix: - Fixed bug of adding custom input validation errors twice when ShowAllErrors
    Message 1 of 5 , Feb 5, 2008
    • 0 Attachment
      Thanks Manuel for the latest update of the class.

      I noticed a particular bug fix:

      - Fixed bug of adding custom input validation errors twice when
      ShowAllErrors option is set.

      I picked this up a while ago but didn't go through the process of
      tracing where the duplication was coming from. Due to time constraints
      I wrote it off as an error I'd made (as the custom input I was
      creating used 2 inputs). So I appreciate that it's now fixed.

      However it's not totally solved. If ErrorMessagePrefix is set (i.e.
      not '') then the prefix is still outputted twice.
      i.e. the error message is now no longer outputted twice, however the
      ErrorMessagePrefix is outputted twice.

      Hope it can be tracked down.

      Cheers, Saul
    • Manuel Lemos
      Hello, ... Can you provide a minimal example that I can reproduce the problem? -- Regards, Manuel Lemos PHP professionals looking for PHP jobs
      Message 2 of 5 , Feb 5, 2008
      • 0 Attachment
        Hello,

        on 02/05/2008 10:33 PM fen.strat said the following:
        > However it's not totally solved. If ErrorMessagePrefix is set (i.e.
        > not '') then the prefix is still outputted twice.
        > i.e. the error message is now no longer outputted twice, however the
        > ErrorMessagePrefix is outputted twice.
        >
        > Hope it can be tracked down.

        Can you provide a minimal example that I can reproduce the problem?

        --

        Regards,
        Manuel Lemos

        PHP professionals looking for PHP jobs
        http://www.phpclasses.org/professionals/

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/
      • fen.strat
        Hi Manuel, ... form_custom_test_class.php : class form_custom_test_class extends form_custom_class { var $client_validate = 0; var $server_validate = 1;
        Message 3 of 5 , Feb 10, 2008
        • 0 Attachment
          Hi Manuel,

          > Can you provide a minimal example that I can reproduce the problem?


          form_custom_test_class.php :
          class form_custom_test_class extends form_custom_class {
          var $client_validate = 0;
          var $server_validate = 1;

          function AddInput(&$form, $arguments) {
          $input_arguments = array(
          'ID'=>$arguments['ID'].'_',
          'NAME'=>$arguments['ID'].'_',
          'TYPE'=>'text',
          'LABEL'=>$arguments['LABEL']
          );
          $form->AddInput($input_arguments);
          return '';
          }

          function ValidateInput(&$form) {
          return 'Custom Input Validation Error Message.';
          }

          }


          test.php
          require('forms.php');
          require('form_custom_test_class.php');
          require('form_layout_vertical.php');

          // Instantiate Form
          $form = new form_class;
          $form->NAME = 'custom_test_form';
          $form->METHOD = 'GET';
          $form->ACTION = '';
          $form->ShowAllErrors = 1;
          $form->ErrorMessagePrefix = '- ';

          // Add Inputs
          $form->AddInput(array(
          'TYPE'=>'text',
          'ID'=>'normal_input',
          'NAME'=>'normal_input',
          'LABEL'=>'Normal Input',
          // 'ValidateAsNotEmpty'=>1,
          'ValidationErrorMessage'=>'Normal Input Validation Error Message.',
          'ValidateOnlyOnServerSide'=>1
          ));
          $form->AddInput(array(
          'TYPE'=>'custom',
          'CustomClass'=>'form_custom_test_class',
          'ID'=>'custom_input_1',
          'LABEL'=>'Custom Input 1'
          ));
          $form->AddInput(array(
          'TYPE'=>'custom',
          'CustomClass'=>'form_custom_test_class',
          'ID'=>'custom_input_2',
          'LABEL'=>'Custom Input 2'
          ));
          $form->AddInput(array(
          'TYPE'=>'hidden',
          'ID'=>'process_form',
          'NAME'=>'process_form',
          'VALUE'=>1
          ));
          $form->AddInput(array(
          'TYPE'=>'submit',
          'ID'=>'btn_submit',
          'VALUE'=>'Submit',
          ));

          // Process Form (if submitted)
          if ($form->WasSubmitted('process_form')) {
          if (($error_html = $form->Validate($verify)) != '') {
          echo '<pre>'.$error_html.'</pre>';
          }
          }

          // Layout Form
          $form->AddInput(array(
          'ID'=>'layout',
          'NAME'=>'layout',
          'TYPE'=>'custom',
          'CustomClass'=>'form_layout_vertical_class',
          'Inputs'=>array(
          'normal_input',
          'custom_input_1_',
          'custom_input_2_',
          'process_form',
          'btn_submit'
          )
          ));

          // Display Form
          $form->StartLayoutCapture();
          $form->AddInputPart('layout');
          $form->EndLayoutCapture();
          $form->DisplayOutput();


          If you submit the form with no input values, you'll notice that the first error displayed is missing the ErrorMessagePrefix.

          If the first field to validate is NOT a custom field (i.e. uncomment 'ValidateAsNotEmpty'=>1 for the normal_input), then there is no problem and the prefix is displayed for each error.

          If this is run with form.php from 2007-06-02 (the last release) then, for the custom inputs, no prefixes are displayed and each error is outputted twice.

          Hope this helps in tracking it down.
          Thanks in advance,
          Saul
        • Manuel Lemos
          Hello, ... Ok, I fixed the bug. You find the fixed version here. Thank you for reporting.
          Message 4 of 5 , Feb 11, 2008
          • 0 Attachment
            Hello,

            on 02/10/2008 10:28 PM fen.strat said the following:
            > If you submit the form with no input values, you'll notice that the
            > first error displayed is missing the ErrorMessagePrefix.
            >
            > If the first field to validate is NOT a custom field (i.e. uncomment
            > 'ValidateAsNotEmpty'=>1 for the normal_input), then there is no problem
            > and the prefix is displayed for each error.
            >
            > If this is run with form.php from 2007-06-02 (the last release) then,
            > for the custom inputs, no prefixes are displayed and each error is
            > outputted twice.

            Ok, I fixed the bug. You find the fixed version here. Thank you for
            reporting.

            http://www.meta-language.net/cvs/forms/forms.php?rev=HEAD;content-type=application%2Foctet-stream

            --

            Regards,
            Manuel Lemos

            PHP professionals looking for PHP jobs
            http://www.phpclasses.org/professionals/

            PHP Classes - Free ready to use OOP components written in PHP
            http://www.phpclasses.org/
          • fen.strat
            Works perfect, thanks Manuel Cheers, Saul
            Message 5 of 5 , Feb 11, 2008
            • 0 Attachment
              Works perfect, thanks Manuel

              Cheers, Saul
            Your message has been successfully submitted and would be delivered to recipients shortly.