|
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 |
BbErSeRkK Smarty Rookie
Joined: 04 Jan 2008 Posts: 14
|
Posted: Thu Apr 17, 2008 12:19 am Post subject: 2 dimensional / multi-dimensional form arrays |
|
|
I asked this in another thread, but I thought I would start a new thread.
Is there a way to easily do this with smarty validate?
I'm doing my head in trying to work out how the internals work, walking through the debugging. But i always get conused
$_POST variable
Code: |
{$_POST['preventative_actions']}
Array (3)
0 => Array (6)
action => ""
details => ""
responsible => ""
due => ""
completed => "on"
completedDate => ""
1 => Array (4)
action => ""
details => ""
responsible => ""
due => ""
2 => Array (4)
action => ""
details => ""
responsible => ""
due => ""
|
PHP VALIDATION CODE EXAMPLE
Code: |
$blnActionsGiven = false;
foreach($_POST['preventative_actions'] as $key => $val){
if ($val['action'] != ''){
$blnActionGiven=true;
if(strlen(trim($val['details'])) == 0){
//make smarty error
}
if(strlen(trim($val['responsible'])) == 0){
//make smarty error
}
if(!isDateValid($val['due'])){
//need to valid date check
//smaryValidate error
}
if(isset($val['completed'])){
//check if completedDate is given
if(isDateValid($val['completedDate'])){
//error - checks valid date & isEmpty
}
}
}
} |
|
|
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
|