forked from GNUsocial/gnu-social
[UI] Display error when submitted form is invalid
This commit is contained in:
@@ -28,7 +28,8 @@ use App\Core\Security;
|
||||
use App\Entity\FileToNote;
|
||||
use App\Entity\Note;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\ClientException;
|
||||
use App\Util\Exceptiion\InvalidFormException;
|
||||
use App\Util\Exception\NoSuchNoteException;
|
||||
use Component\Media\Media;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
@@ -42,7 +43,7 @@ class Post
|
||||
{
|
||||
$note = DB::find('note', ['id' => $reply_to]);
|
||||
if ($note == null) {
|
||||
throw new ClientException(_m('No such note'));
|
||||
throw new NoSuchNoteException();
|
||||
}
|
||||
|
||||
$actor_id = Common::ensureLoggedIn()->getId();
|
||||
@@ -61,7 +62,7 @@ class Post
|
||||
if ($form->isValid()) {
|
||||
self::storeNote($actor_id, $data['content'], $data['attachments'], $is_local = true, $data['reply_to'], null);
|
||||
} else {
|
||||
// TODO display errors
|
||||
throw new InvalidFormException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,7 @@ use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Module;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exceptiion\InvalidFormException;
|
||||
use App\Util\Exception\RedirectException;
|
||||
use Component\Posting\Controller as C;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@@ -71,7 +72,7 @@ class Posting extends Module
|
||||
C\Post::storeNote($actor_id, $data['content'], $data['attachments'], $is_local = true);
|
||||
throw new RedirectException();
|
||||
} else {
|
||||
// TODO Display error
|
||||
throw new InvalidFormException();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user