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

Upgrading SmartyValidate from 2.2 to current

 
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
krypted
Smarty n00b


Joined: 11 Nov 2008
Posts: 1

PostPosted: Tue Nov 11, 2008 4:26 am    Post subject: Upgrading SmartyValidate from 2.2 to current Reply with quote

Recently I decided to upgrade my site from php4 to php5, along with it, smarty received an upgrade too. Recently, I have noticed that none of my existing form validations work anymore.

Here is what I found,

in Version 2.2 in the is_valid() method, it processed all the form fields and made them accessible in the template before it reached the smarty template... (I had an array available with all failed fields before accessing TPL)

notice: the append and assign are both evaluated and set (a perk).
if(!$_sess[$_key]['valid']) {

$_failed_fields[] = $_field;

if(isset($_append))
$_smarty_assign_fields[$_append][] = $_message;

if(isset($_assign))
$_smarty_assign_fields[$_assign] = $_message;

$_ret = false;

if($_sess[$_key]['halt'])
break;

}

In 2.9 (in the libs/validate_function.php ). append and assign are now mutually exclusive. You can only have one or other (problem number one for me).

Problem number 2. The assign/append are now evaluated as the TPL is being parsed, therefore, they are not all available immediately... For example, I am printing all the failed fields top of the page, this breaks that functionality, since no form fields have been evaluated yet.


if(isset($params['assign'])) {

$smarty->assign($params['assign'], $_sess['validators'] [$_validator_key]['message']);

} elseif (isset($params['append'])) {

$smarty->append($params['append'], $_sess['validators'][$_validator_key]['message']);

} else {

// no assign or append, so echo message
echo $_sess['validators'][$_validator_key]['message'];
}

Is there a reason why append and assign are mutually exclusive now?

what is the gain behind moving the append/assign from SmartyValidate to validate_function.php, so it evaluates the fields as it builds out the template?

Any input on this would be great. I'd hate to redo all my forms/validations.

Thanks
Damian.
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