code: public function getAttributeOptions(GetPropertyOptionsEvent $event)
      {
          if (!$this->wantToHandle($event) || ($event->getPropertyName() !== 'attr_id')) {
              return;
          }
  
          $model     = $event->getModel();
          $metaModel = $this->getMetaModelFromModel($model);
  
          if (!$metaModel) {
              return;
          }
  
          $options = [];
  
          // Fetch all attributes that exist in other settings.
          $alreadyTaken = $this->connection->createQueryBuilder()
              ->select('attr_id')
              ->from('tl_metamodel_dcasetting')
              ->where('dcatype="attribute"')
              ->andWhere('pid=:pid')
              ->setParameter('pid', $model->getProperty('pid'));
  
          // If an attribute is selected, we want to keep it in the list.
          if (!empty($attributeId = $model->getProperty('attr_id'))) {
              $alreadyTaken
                  ->andWhere('attr_id<>:id')
                  ->setParameter('id', $attributeId);
          }
          $alreadyTaken = $alreadyTaken->execute()->fetchAll(\PDO::FETCH_COLUMN);
  
          foreach ($metaModel->getAttributes() as $attribute) {
              if ($attribute instanceof IInternal || in_array($attribute->get('id'), $alreadyTaken)) {
                  continue;
              }
              $options[$attribute->get('id')] = sprintf(
                  '%s [%s]',
                  $attribute->getName(),
                  $attribute->get('type')
              );
          }
  
          $event->setOptions($options);
      }
docs: Retrieve the options for the attributes.
  
  @param GetPropertyOptionsEvent $event The event.
  
  @return void