Пример #1
0
# set inline error messages
$form->useInlineErrorMessages = true;
# init helper variable for messages. in case some message is stored in session, use it
if (!empty($_SESSION['message'])) {
    $message = $_SESSION['message'];
    $_SESSION['message'] = null;
} else {
    $message = null;
}
# set onSubmit action
$form->onSubmit(function ($form, $isValid) {
    if (!$isValid) {
        $message = "Vall-I does not like inserted data, saying: " . implode(", ", $form->getErrorMessages());
    } else {
        # Here could be some backend logic, for example inserting into database etc... and then redirection
        $message = "Vall-I is satisfied with the following data, good job!<pre>" . print_r($form->getData(), true) . "</pre>";
    }
    redirect("basics.php", $message);
}, get('data'));
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Basic usage of Vall-I</title>
		<style>
			.InvalidElement
			{
				border: 2px solid red;
			}
		</style>