Initial Commit
This commit is contained in:
59
local/modules/SliderRevolution/Form/ConfigurationForm.php
Normal file
59
local/modules/SliderRevolution/Form/ConfigurationForm.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia 2 FrancoDePort payment module */
|
||||
/* */
|
||||
/* Copyright (c) CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SliderRevolution\Form;
|
||||
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ConfigurationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add(
|
||||
SliderRevolution::SLIDER_ID,
|
||||
'text',
|
||||
[
|
||||
'constraints' => [new NotBlank()],
|
||||
'label' => $this->translator->trans('Identifiant du slider à afficher', [], SliderRevolution::DOMAIN_NAME),
|
||||
'data' => SliderRevolution::getConfigValue(SliderRevolution::SLIDER_ID),
|
||||
]
|
||||
)
|
||||
->add(
|
||||
SliderRevolution::FIN_COMPTE_A_REBOURS,
|
||||
'text',
|
||||
[
|
||||
'required' => false,
|
||||
'constraints' => [new Callback([ "methods" => [[ $this, "checkDate" ]]]),],
|
||||
'label' => $this->translator->trans('Date de fin de compte à rebours (format JJ/MM/AAAA HH:MM:SS)', [], SliderRevolution::DOMAIN_NAME),
|
||||
'data' => SliderRevolution::getConfigValue(SliderRevolution::FIN_COMPTE_A_REBOURS, ''),
|
||||
'label_attr' => [
|
||||
'help' => $this->translator->trans("Si une date est indiquée, un compte à rebours sera affiché sur les sliders qui ont les layer texte requises (ID t_days, t_hours, t_minutes et t_seconds), cf https://www.themepunch.com/revsliderjquery-doc/countdown", [], SliderRevolution::DOMAIN_NAME)
|
||||
]
|
||||
]
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function checkDate($value, ExecutionContextInterface $context)
|
||||
{
|
||||
if (! empty($value) && false === \DateTime::createFromFormat('d/m/Y H:i:s', $value)) {
|
||||
$context->addViolation("Merci d'indiquer une date au format JJ/MM/AAAA HH:MM:SS, par exemple 17/11/2018 12:30:00");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user