Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyValidate & SmartyPaginate - 2 minor bugs

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Thu Oct 27, 2005 4:57 pm    Post subject: SmartyValidate & SmartyPaginate - 2 minor bugs Reply with quote

I'll admit up front that I might have implemented these 2 add-ons incorrectly, but these are my observations.

I am using PHP 5.05 with full error reporting on my development servers.

The reason I say these are minor is that they are just PHP Notices and do not hinder the programs from functioning other than being minor annoyances.

SmartyPaginate -- function.paginate_middle.php

Line 97 - AFAIK this is supposed to initialize the $_display_pages variable, but it looks like a typo in the variable name
Code:
$_displayed_pages = 0;

should be
Code:
$_display_pages = 0;


Line 125 & 127 - These lines add the links for each page/record group, except the $_ret variable is never initialized so a Notice is thrown on the first iteration of the while loop.
I added in at line 38 --
Code:
$_ret='';



SmartyValidate --

In my template, in the fields I put in the form variables as in the example listed in the documentation.
Code:

    Full Name: <input type="text" name="FullName" value="{$FullName|escape}">
    {validate form="form" id="fullname" message="Full Name Cannot Be Empty!"}


But when the form is first generated the {$FullName} variable is not filled in yet. This throws up a Notice about an undefined index. The quick resolution was to do this --
Code:

    Full Name: <input type="text" name="FullName" value="{$FullName|default:""|escape}">
    {validate form="form" id="fullname" message="Full Name Cannot Be Empty!"}


Kind of a pain, because I will have to set the default parameter on every formfield.. Is there a way it could be set up to send in the variables as blank on the first iteration?


Anyway, just wanted to give a heads up, and also to say thanks to Monte for these awesome add-ons that I am trying to fully utilize in my applications.

Regards,
Owen
Back to top
View user's profile Send private message Visit poster's website
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Sat Apr 15, 2006 12:30 pm    Post subject: Reply with quote

has this been fixed since then?

Because I have the same problem. On the first run of my form, I'll always get "Undefined Index: ..." errors...
Back to top
View user's profile Send private message
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Sat Apr 15, 2006 3:16 pm    Post subject: Reply with quote

I think I have made a quick'n'dirty solution to this:
When a validator is registered, an empty string is assigned to the corresponding value.

In SmartyValidate.class.php find:
Code:

   $_validator = array();
        foreach($_field as $_key => $_val) {
            if($_key == 0)
                $_validator['field'] = $_val;
            else
            {
                $_field_name = 'field';
                $_field_name .= $_key + 1;
                $_validator[$_field_name] = $_val;   
            }
        }

and replace with:
Code:

   $_validator = array();

        //get rid of the undefined indexes
        $_smarty_obj =& SmartyValidate::_object_instance('Smarty', $_dummy);               

        foreach($_field as $_key => $_val) {
            if($_key == 0)
            {
                $_validator['field'] = $_val;

                //get rid of the undefined indexes
                $_smarty_obj->assign($_val, '');
            }
            else
            {
                $_field_name = 'field';
                $_field_name .= $_key + 1;
                $_validator[$_field_name] = $_val;   

                //get rid of the undefined indexes
                $_smarty_obj->assign($_val, '');
            }
        }


Hope it works
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP