I have form component with four CheckboxLists. There are set own validation rules (PHP, JavaScript), but if these rules are removed, error is still thrown. The entire form contains only four checkboxes and a submit button. The form is manually rendered and Firefox Console is blank. If I leave the tab and come back, console contains "too much recursion" and "stack overflow" on this line and this line. Javascript validation during form submitting fails, own validation rules are not called.
When I use netteForms.js version 2.3.10, everything is ok and JavaScript validation passes.
data-nette-rules attributes are the same for Nette 2.3.10 and Nette 2.4.0 (20170119).
public function getControl()
{
$this->setOption('rendered', TRUE);
$form = new Form();
$container = $form->addContainer($this->getHtmlName());
$regions = $municipalities = $departments = [];
if ($this->regionsEnabled === TRUE)
{
$regions = $container->addCheckboxList('regions', NULL, $this->regionsList);
$regions->setDefaultValue($this->regions)
->getSeparatorPrototype()
->setName(NULL);
$regions->getLabelPrototype()
->setClass('checkbox-inline');
}
if ($this->municipalitiesEnabled === TRUE)
{
$municipalities = $container->addCheckboxList('municipalities', NULL, $this->municipalitiesList);
$municipalities->setDefaultValue($this->municipalities)
->getSeparatorPrototype()
->setName(NULL);
$municipalities->getLabelPrototype()
->setClass('checkbox-inline');
}
if ($this->departmentsEnabled === TRUE)
{
$departments = $container->addCheckboxList('departments', NULL, $this->departmentsList);
$departments->setDefaultValue($this->departments)
->getSeparatorPrototype()
->setName(NULL);
$departments->getLabelPrototype()
->setClass('checkbox-inline');
}
if ($this->municipalitiesEnabled === TRUE || $this->departmentsEnabled === TRUE)
{
$districts = $container->addCheckboxList('districts', NULL, $this->districtsList);
$districts->setDefaultValue($this->districts)
->getSeparatorPrototype()
->setName(NULL);
$districts->getLabelPrototype()
->setClass('checkbox-inline');
}
$control = Html::el();
if ($this->regionsEnabled === TRUE)
{
$regions->addRule(__CLASS__.'::validateOrganization', static::$validationMessages['organization'], [$regions, $municipalities, $departments]);
$control->addHtml(Html::el('p', Html::el('small', Html::el('strong', 'Kraj')))->class('form-control-static'))
->addHtml($regions->getControl());
}
if ($this->municipalitiesEnabled === TRUE)
{
$municipalities->addRule(__CLASS__.'::validateOrganization', static::$validationMessages['organization'], [$regions, $municipalities, $departments])
->addRule(__CLASS__.'::validateDistrict', static::$validationMessages['district'], [$regions, $municipalities, $departments, $districts]);
$control->addHtml(Html::el('p', Html::el('small', Html::el('strong', 'Obce')))->class('form-control-static'))
->addHtml($municipalities->getControl());
}
if ($this->departmentsEnabled === TRUE)
{
$departments->addRule(__CLASS__.'::validateOrganization', static::$validationMessages['organization'], [$regions, $municipalities, $departments])
->addRule(__CLASS__.'::validateDistrict', static::$validationMessages['district'], [$regions, $municipalities, $departments, $districts]);
$control->addHtml(Html::el('p', Html::el('small', Html::el('strong', 'Příspěvkové organizace')))->class('form-control-static'))
->addHtml($departments->getControl());
}
if ($this->municipalitiesEnabled === TRUE || $this->departmentsEnabled === TRUE)
{
$control->addHtml(Html::el('hr'))
->addHtml(Html::el('p', Html::el('small', Html::el('strong', 'Okres')))->class('form-control-static'))
->addHtml($districts->getControl());
}
return $control;
}
public static function validateOrganization(IControl $control)
{
return count($control->regions) > 0 || count($control->municipalities) > 0 || count($control->departments) > 0;
}
public static function validateDistrict(IControl $control)
{
return (count($control->regions) > 0 && count($control->municipalities) === 0 && count($control->departments) === 0)
|| count($control->districts) > 0;
}
Description
I have form component with four CheckboxLists. There are set own validation rules (PHP, JavaScript), but if these rules are removed, error is still thrown. The entire form contains only four checkboxes and a submit button. The form is manually rendered and Firefox Console is blank. If I leave the tab and come back, console contains "too much recursion" and "stack overflow" on this line and this line. Javascript validation during form submitting fails, own validation rules are not called.
When I use netteForms.js version 2.3.10, everything is ok and JavaScript validation passes.
data-nette-rules attributes are the same for Nette 2.3.10 and Nette 2.4.0 (20170119).
Steps To Reproduce