Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

2 dimensional / multi-dimensional form arrays

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
BbErSeRkK
Smarty Rookie


Joined: 04 Jan 2008
Posts: 14

PostPosted: Thu Apr 17, 2008 12:19 am    Post subject: 2 dimensional / multi-dimensional form arrays Reply with quote

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 Confused

$_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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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