O
O
ozornick2019-09-19 17:41:33
symfony
ozornick, 2019-09-19 17:41:33

Symfony: what and when to throw exceptions (validate)?

Something I read out the docks on the forms, and then the question has matured like a banal one, but I can’t figure it out.
Actually how to write a handler in the classical way. I used to do this in pure PHP:

<?php
$error = [];

if (false) {
    $error['name_empty'] = 'Enter your name';
}

if (false) {
    $error['text_empty'] = 'Enter article text';
}

if (!$error) {
    // save/redirect
}

// допустим внизу форма или HTML просто
echo '<p>' . implode(', ', $error) . '</p>';

Can you post links to this thread.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question