Hello,
I have an Express Object with association.
I make form to add entries to my Express Object. In this form I add my association and I didn’t check the box “Yes, this form element is required”.
If I want to add entry to my object, I cannot do this if I have not selected an attribute of the associated element. I have this error “You must select a valid (name of my Association)”
Is there someone to help me with this problem? Is this a bug?
Best regards
Brice
I find the solution of this bug.
On the version 8.5.7 in the file concrete/src/Express/Form/Control/Validator/AssociationControlValidator.php
I add this change :
public function validateRequest(Control $control, Request $request)
{
if ($control->isRequired()) {
$associationValue = $request->request->get('express_association_' . $control->getId());
if (!$associationValue) {
/**
* @var AssociationControl
*/
$this->errorList->add(t('You must select a valid %s', $control->getAssociation()->getTargetEntity()->getName()));
}
}
return $this->errorList;
}
It missed if ($control->isRequired()) {
can you post that as an issue with suggested fix on GitHub.
(or if feeling adventurous, also post a pull request fixing the code)
Ok I will do that. Thanks