new form type to select a daytime in system-configuration (#1895)
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Form\Model\Configuration;
|
||||
use App\Form\Model\SystemConfiguration as SystemConfigurationModel;
|
||||
use App\Form\SystemConfigurationForm;
|
||||
use App\Form\Type\DateTimeTextType;
|
||||
use App\Form\Type\DayTimeType;
|
||||
use App\Form\Type\LanguageType;
|
||||
use App\Form\Type\RoundingModeType;
|
||||
use App\Form\Type\SkinType;
|
||||
@@ -23,6 +24,7 @@ use App\Form\Type\WeekDaysType;
|
||||
use App\Form\Type\YesNoType;
|
||||
use App\Repository\ConfigurationRepository;
|
||||
use App\Validator\Constraints\DateTimeFormat;
|
||||
use App\Validator\Constraints\TimeFormat;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
@@ -34,8 +36,8 @@ use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Validator\Constraints\DateTime;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
|
||||
@@ -136,15 +138,19 @@ final class SystemConfigurationController extends AbstractController
|
||||
$form = $this->createConfigurationsForm($configModel);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
try {
|
||||
$this->repository->saveSystemConfiguration($form->getData());
|
||||
$this->flashSuccess('action.update.success');
|
||||
} catch (\Exception $ex) {
|
||||
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
|
||||
}
|
||||
if ($form->isSubmitted()) {
|
||||
if ($form->isValid()) {
|
||||
try {
|
||||
$this->repository->saveSystemConfiguration($form->getData());
|
||||
$this->flashSuccess('action.update.success');
|
||||
} catch (\Exception $ex) {
|
||||
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('system_configuration');
|
||||
return $this->redirectToRoute('system_configuration');
|
||||
} else {
|
||||
$this->flashError('action.update.error', ['%reason%' => 'Validation problem']);
|
||||
}
|
||||
}
|
||||
|
||||
$configSettings = $this->getInitializedConfigurations();
|
||||
@@ -393,23 +399,23 @@ final class SystemConfigurationController extends AbstractController
|
||||
(new Configuration())
|
||||
->setName('calendar.businessHours.begin')
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setType(TextType::class)
|
||||
->setConstraints([new DateTime(['format' => 'H:i']), new NotNull()]),
|
||||
->setType(DayTimeType::class)
|
||||
->setConstraints([new NotBlank(), new TimeFormat()]),
|
||||
(new Configuration())
|
||||
->setName('calendar.businessHours.end')
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setType(TextType::class)
|
||||
->setConstraints([new DateTime(['format' => 'H:i']), new NotNull()]),
|
||||
->setType(DayTimeType::class)
|
||||
->setConstraints([new NotBlank(), new TimeFormat()]),
|
||||
(new Configuration())
|
||||
->setName('calendar.visibleHours.begin')
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setType(TextType::class)
|
||||
->setConstraints([new DateTime(['format' => 'H:i']), new NotNull()]),
|
||||
->setType(DayTimeType::class)
|
||||
->setConstraints([new NotBlank(), new TimeFormat()]),
|
||||
(new Configuration())
|
||||
->setName('calendar.visibleHours.end')
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setType(TextType::class)
|
||||
->setConstraints([new DateTime(['format' => 'H:i']), new NotNull()]),
|
||||
->setType(DayTimeType::class)
|
||||
->setConstraints([new NotBlank(), new TimeFormat()]),
|
||||
(new Configuration())
|
||||
->setName('calendar.slot_duration')
|
||||
->setTranslationDomain('system-configuration')
|
||||
|
||||
Reference in New Issue
Block a user