You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to use a custom setter method on a select in combination with "$event.target.value" (as mentioned in the docs), the setter raises an exception if you try to select the empty value (value=""), because the value is not transmitted to the backend.
None empty values work as expected.
But in case of an empty value the actionQueue.0.payload.name is set_flavor() instead of set_flavor('')
The exception is:
File "django-unicorn\django_unicorn\views\action_parsers\call_method.py", line 157, in _call_method_name
parsed_args.append(cast_value(type_hint, args[len(parsed_args)]))
IndexError: tuple index out of range
HTML example:
<selectunicorn:change="set_flavor($event.target.value)" id="select-custom-setter"><optionvalue="">-- select --</option>
{% for flavor in flavors %}
<optionvalue="{{ flavor }}">{{ flavor }}</option>
{% endfor %}
</select>
If you try to use a custom setter method on a select in combination with "$event.target.value" (as mentioned in the docs), the setter raises an exception if you try to select the empty value (value=""), because the value is not transmitted to the backend.
None empty values work as expected.
But in case of an empty value the
actionQueue.0.payload.name
isset_flavor()
instead ofset_flavor('')
The exception is:
File "django-unicorn\django_unicorn\views\action_parsers\call_method.py", line 157, in _call_method_name
parsed_args.append(cast_value(type_hint, args[len(parsed_args)]))
IndexError: tuple index out of range
HTML example:
Component example:
In my case the error still exists if I change the custom setter definition to
set_flavor(self, value: str = "")
with a default value.Minimal example (extension of your html-input example):
example_to_demonstrate_a_bug,_if_you_use_a_custom_setter_function_that_is_executed.patch
The text was updated successfully, but these errors were encountered: