I can't get my head around this easy step-by-step validation. I already had it in a while-loop, but found it even more horrible than with beginner-like if-cases. I still think though, that it could be written a bit simpler (and maybe improve readablity).
What I'm doing here ? Basically I check for required input fields and if they fail to validate, I need to go to another level of output, check for other required fields, and so on...
It already is a quite simple thing to do, but in the course of development it will get bigger and bigger, so it needs to stay simple.
// CHECK FOR REQUIRED PROPERTIES
if($properties['step'] == 2)
{
$req = array('cshort','cid');
foreach($req as $required)
{
if(!validate_var($req,$properties[$req]) || empty($properties[$req]))
{
$step = 1;
}
}
}
if($properties['step'] == 1)
{
$req = array('cshort');
foreach($req as $required)
{
if(!validate_var($req,$properties[$req]) || empty($properties[$req]))
{
$step = 1;
return $st
}
}
}