diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/field.py b/src/collective/volto/formsupport/restapi/services/submit_form/field.py index b45fa11f..326a60f9 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/field.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/field.py @@ -1,4 +1,5 @@ import re +from typing import Any from collective.volto.formsupport.validation import getValidations @@ -30,7 +31,7 @@ def value_is_not(value, target_value): class Field: - def __init__(self, field_data): + def __init__(self, field_data: dict[str, Any]): def _attribute(attribute_name: str): setattr(self, attribute_name, field_data.get(attribute_name)) @@ -40,11 +41,11 @@ def _attribute(attribute_name: str): _attribute("show_when_is") _attribute("show_when_to") _attribute("input_values") - _attribute("required") _attribute("widget") _attribute("use_as_reply_to") _attribute("use_as_reply_bcc") - _attribute("validations") + self.required = field_data.get("required") + self.validations = field_data.get("validations") self._display_value_mapping = field_data.get("dislpay_value_mapping") self._value = field_data.get("value", "") self._custom_field_id = field_data.get("custom_field_id") @@ -62,7 +63,7 @@ def internal_value(self): return self._value def should_show(self, show_when_is, target_value): - always_show_validator = show_when_validators['always'] + always_show_validator = show_when_validators["always"] if not show_when_is: return always_show_validator() show_when_validator = show_when_validators[show_when_is] @@ -86,6 +87,8 @@ def send_in_email(self): def validate(self): # Making sure we've got a validation that actually exists. + if not self._value and not self.required: + breakpoint() available_validations = [ validation for validationId, validation in getValidations()