mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +02:00
N°6414 Validator refactoring
New AbstractValidator class, with new method Validate All existing validators are now children of AbstractRegexpValidator Handle validators JS counterparts in renderers : only regexp validators are implemented client side
This commit is contained in:
@@ -27,7 +27,9 @@ use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockF
|
||||
use Combodo\iTop\Application\UI\Base\Component\Input\SelectUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
|
||||
use Combodo\iTop\Form\Field\SelectObjectField;
|
||||
use Combodo\iTop\Form\Validator\AbstractRegexpValidator;
|
||||
use Combodo\iTop\Form\Validator\MandatoryValidator;
|
||||
use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
use Combodo\iTop\Renderer\BlockRenderer;
|
||||
use Combodo\iTop\Renderer\FieldRenderer;
|
||||
use DBObjectSet;
|
||||
@@ -245,16 +247,19 @@ JS
|
||||
$oOutput->AddHtml((BlockRenderer::RenderBlockTemplates($oBlock)));
|
||||
// JS Form field widget construct
|
||||
$aValidators = array();
|
||||
foreach ($this->oField->GetValidators() as $oValidator)
|
||||
{
|
||||
if ($oValidator::GetName() == 'notemptyextkey')
|
||||
{
|
||||
foreach ($this->oField->GetValidators() as $oValidator) {
|
||||
if (false === ($oValidator instanceof AbstractRegexpValidator)) {
|
||||
// no JS counterpart, so skipping !
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($oValidator instanceof NotEmptyExtKeyValidator) {
|
||||
// The autocomplete widget returns an empty string if the value is undefined (and the select has been aligned with this behavior)
|
||||
$oValidator = new MandatoryValidator();
|
||||
}
|
||||
$aValidators[$oValidator::GetName()] = array(
|
||||
'reg_exp' => $oValidator->GetRegExp(),
|
||||
'message' => Dict::S($oValidator->GetErrorMessage())
|
||||
'message' => Dict::S($oValidator->GetErrorMessage()),
|
||||
);
|
||||
}
|
||||
$sValidators = json_encode($aValidators);
|
||||
|
||||
Reference in New Issue
Block a user