|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TGKnIght Smarty Junkie
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
Posted: Thu Oct 27, 2005 4:57 pm Post subject: SmartyValidate & SmartyPaginate - 2 minor bugs |
|
|
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 --
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 |
|
Dieter Smarty Rookie
Joined: 08 Sep 2003 Posts: 9
|
Posted: Sat Apr 15, 2006 12:30 pm Post subject: |
|
|
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 |
|
Dieter Smarty Rookie
Joined: 08 Sep 2003 Posts: 9
|
Posted: Sat Apr 15, 2006 3:16 pm Post subject: |
|
|
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 |
|
|
|
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
|