Adds an element to the form based on the entity attribute.

def add(self, attr, field_class=None, **options):
        """Adds an element to the form based on the entity attribute."""
        # print(attr.name, attr.py_type, getattr(attr, 'set', None))
        # print(dir(attr))
        # print(attr, attr.is_relation, attr.is_collection)
        # print(attr.is_pk, attr.auto, attr.is_unique, attr.is_part_of_unique_index, attr.composite_keys)

        def add(klass, options):
            if klass:
                self._fields[attr.name] = field_class(**options) if field_class else klass(**options)
            return self

        kwargs = {
            'label': attr.name,
            'default': attr.default,
            'validators': [],
        }
        kwargs.update(options)

        if attr.is_pk:
            return add(*self._create_pk_field(attr, kwargs))

        if attr.is_collection:
            return add(*self._create_collection_field(attr, kwargs))

        validator = wtf_validators.InputRequired() if attr.is_required and not attr.is_pk else wtf_validators.Optional()
        kwargs['validators'].insert(0, validator)

        if attr.is_relation:
            return add(*self._create_relational_field(attr, kwargs))

        return add(*self._create_plain_field(attr, kwargs))