form+configpanel: reflect Section optional value to all its Options

This commit is contained in:
axolotle 2023-04-22 18:47:05 +02:00
parent fccb291d78
commit 48f882ecd3
2 changed files with 3 additions and 3 deletions

View file

@ -95,9 +95,10 @@ class SectionModel(ContainerModel, OptionsModel):
services: list[str] = [], services: list[str] = [],
help: Union[Translation, None] = None, help: Union[Translation, None] = None,
visible: Union[bool, str] = True, visible: Union[bool, str] = True,
optional: bool = True,
**kwargs, **kwargs,
) -> None: ) -> None:
options = self.options_dict_to_list(kwargs, optional=True) options = self.options_dict_to_list(kwargs, optional=optional)
ContainerModel.__init__( ContainerModel.__init__(
self, self,

View file

@ -1308,9 +1308,8 @@ class OptionsModel(BaseModel):
return [ return [
option option
| { | {
"id": id_, "id": option.get("id", id_),
"type": option.get("type", "string"), "type": option.get("type", "string"),
# ConfigPanel options needs to be set as optional by default
"optional": option.get("optional", optional), "optional": option.get("optional", optional),
} }
for id_, option in options.items() for id_, option in options.items()