Styling sketch errors
I created a registry page that will print errors if the check fails. Errors will always be displayed at the top of the form. I want them to appear below the form, so I added a div. But that doesn't work as each error has a separate div, not all errors in one div. How do I make all the mistakes in one div that is under the form?
if (Input::exists()) {
if (Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
//validation
if ($validation->passed()) {
$user = new User();
//pass information to database
Session::flash('home', 'You have been registered and can now log in!');
Redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
} else {
foreach ($validation->errors() as $error) {
echo '<div id="r-error"><p id="error">', $error, '</p></div>';
}
}
}
}
?>
+3
source to share
1 answer
Just take out <div>
of the loop. Cut a hole before the cycle and then a close echo after the cycle.
if (Input::exists()) {
if (Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
//validation
if ($validation->passed()) {
$user = new User();
//pass information to database
Session::flash('home', 'You have been registered and can now log in!');
Redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
} else {
echo '<div id="r-error">';
foreach ($validation->errors() as $error) {
echo '<p class="error">', $error, '</p>';
}
echo '</div>';
}
}
}
?>
+3
source to share