Skip to content

Commit

Permalink
fix: allow overriding the entity form
Browse files Browse the repository at this point in the history
Closes: #238
  • Loading branch information
b1rger committed Oct 5, 2023
1 parent 8011894 commit 2a65fff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apis_core/apis_entities/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from apis_core.apis_metainfo.models import Uri, Collection
from apis_core.apis_vocabularies.models import TextType
from apis_core.utils import DateParser, caching
from apis_core.utils import DateParser, caching, settings as apis_settings
from .fields import ListSelect2, Select2Multiple

if "apis_highlighter" in settings.INSTALLED_APPS:
Expand Down Expand Up @@ -42,6 +42,9 @@ def get_entities_form(entity):
:return: GenericEntitiesForm class
"""

if form := apis_settings.get_entity_settings_by_modelname(entity).get("form"):
return form

class GenericEntitiesForm(forms.ModelForm):
class Meta:
model = caching.get_entity_class_of_name(entity)
Expand Down
1 change: 1 addition & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ The example above is the default setting of the Place entity.
allows to merge several entities in one target entity at once.
``search`` is an array and sets the fields that the search field searches.
``form_order`` defines the order of the fields in the metadata form of the respective entity.
``form`` allows you to set a custom form for the entity, instead of the default `apis_entities.forms.GenericEntityForm`
``table_fields`` sets the default columns to show in the list views.
``additional_cols`` allows to set the columns that user can add to the result view.
``relations_per_page`` allows to set the number of relations listed before pagination begins
Expand Down

0 comments on commit 2a65fff

Please sign in to comment.