signebedi / libreforms-fastapi

FastAPI implementation of the libreForms spec
GNU Affero General Public License v3.0
1 stars 1 forks source link

Implement `create_submission` built in event hook behavior #342

Closed signebedi closed 2 months ago

signebedi commented 2 months ago

This will look something like:

create_submission:
  form_name: example_form
  values:
    field_name_1:
      method: static
      value: "This text will always be the same"
    field_name_2:
      method: from_field
      value: some_field_name
    field_name_3:
      method: from_field
      value: __metadata__some_metadata_field

This will create an example_form form submission with the values set in the values dict. Should we support setting metadata fields too, just using the __metadata__ field name prefix in the values dict keys?

Originally posted by @signebedi in https://github.com/signebedi/libreforms-fastapi/issues/210#issuecomment-2327055595

signebedi commented 2 months ago

Opted against setting metadata fields in the new target form, except for the created_by field which is done by default. We may want to revisit this decision in the future... the logic change is very straightforward if we want to add something to parse target __metadata__ fields and append these to the metadata dict...

signebedi commented 2 months ago

We should consider running the data through the pydantic model... there are pros and cons, but it will help enforce consistency and prevent breaking...