/**
  * @inheritdoc
  */
 public function buildValuesForm(FormInterface $form, FamilyInterface $family, DataInterface $data = null, array $options = [])
 {
     $family = $data->getFamily();
     foreach ($family->getAttributes() as $attribute) {
         if (!$attribute->getGroup()) {
             // First only the attributes with no group
             $this->addAttribute($form, $attribute, $family);
         }
     }
     foreach ($family->getAttributes() as $attribute) {
         if ($attribute->getGroup()) {
             // Then only the one with a group
             $tabName = '__tab_' . $family->getCode() . '_' . $attribute->getGroup();
             if (!$form->has($tabName)) {
                 $tabOptions = ['label' => $this->getGroupLabel($family, $attribute->getGroup()), 'inherit_data' => true];
                 $icon = $this->getGroupIcon($family, $attribute->getGroup());
                 if ($icon) {
                     $tabOptions['icon'] = $icon;
                 }
                 $form->add($tabName, TabType::class, $tabOptions);
             }
             $this->addAttribute($form->get($tabName), $attribute, $family);
         }
     }
 }
 /**
  * @param ExecutionContextInterface $context
  * @param AttributeInterface        $attribute
  * @param DataInterface             $data
  *
  * @throws Exception
  */
 protected function checkUnique(ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data)
 {
     $valueData = $data->get($attribute->getCode());
     if ($attribute->getType() instanceof IdentifierAttributeType) {
         /** @var DataRepository $repo */
         $repo = $this->doctrine->getRepository($data->getFamily()->getDataClass());
         $result = $repo->findByIdentifier($data->getFamily(), $valueData);
         if ($result && $result->getId() !== $data->getId()) {
             $this->buildAttributeViolation($context, $attribute, 'unique', $valueData);
         }
         return;
     }
     /** @var ValueRepository $repo */
     $repo = $this->doctrine->getRepository($data->getFamily()->getValueClass());
     $values = $repo->findBy(['attributeCode' => $attribute->getCode(), $attribute->getType()->getDatabaseType() => $valueData]);
     /** @var ValueInterface $value */
     foreach ($values as $value) {
         if (!$value->getData()) {
             continue;
             // @warning this should not occur ! Log an error
         }
         if ($value->getData()->getId() !== $data->getId()) {
             $this->buildAttributeViolation($context, $attribute, 'unique', $valueData);
             return;
         }
     }
 }