Fix form validation
This commit is contained in:
parent
79ba41a983
commit
c46cf0fdb7
|
@ -40,13 +40,11 @@ class EditController extends Controller
|
|||
$form->submit($request);
|
||||
$data = $form->getData();
|
||||
|
||||
if (empty($form->getData()['content']) && !$request->files->has('file')) {
|
||||
if (empty($form->getData()['content']) && $form->get('file')->getData()) {
|
||||
$data['content'] = file_get_contents($form->get('file')->getData()->getPathName());
|
||||
unset($data['file']);
|
||||
} elseif (empty($form->getData()['content'])) {
|
||||
$form->get('content')->addError(new FormError($app['translator']->trans('form.error.not_blank')));
|
||||
} elseif (empty($form->getData()['content']) && $request->files->has('file')) {
|
||||
if (count($form->get('file')->getErrors()) === 0) {
|
||||
$data['content'] = file_get_contents($form->get('file')->getData()->getPathName());
|
||||
unset($data['file']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($form->isValid()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
{% set theme_settings = app.settings.theme %}
|
||||
{% set security_dettings = app.settings.security %}
|
||||
{% set security_settings = app.settings.security %}
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
{% block css %}
|
||||
|
@ -56,14 +56,14 @@
|
|||
{{ 'app.menu.my.logout.title'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% elseif security_dettings.enable_login %}
|
||||
{% elseif security_settings.enable_login %}
|
||||
<li>
|
||||
<a href="{{ path('login') }}">
|
||||
{{ 'app.menu.my.login.title'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if security_dettings.enable_registration %}
|
||||
{% if security_settings.enable_registration %}
|
||||
<li>
|
||||
<a href="{{ path('register') }}">
|
||||
{{ 'app.menu.my.register.title'|trans }}
|
||||
|
|
Loading…
Reference in New Issue