<?php
// https://git.andweb.cz/brandcloud/app/-/blob/bcnew/app/BrandCloudModule/components/SharingForm.php#L148
$form->addSubmit('share', 'Share')
->onInvalidClick[] = function () use ($form) {
// we have to set recipients as items to revalidate recipients field
// TODO: posibly change multiselectbox to some other implementation which works only with raw value
if ($form['sharing_type']->getValue() === 'email') {
$form['recipients']->setItems((array) $form['recipients']->getRawValue(), false);
$form->validate();
}
};
$form->onValidate[] = [$this, 'validateForm'];
$form->onSubmit[] = [$this, 'submitForm'];
$form->onSuccess[] = [$this, 'successForm'];
$form->setDefaults($this->getFormDefaults());
return $form;