mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
form: add legacy "name" attr
This commit is contained in:
parent
a574855a03
commit
774b11cbbe
1 changed files with 7 additions and 0 deletions
|
@ -285,6 +285,7 @@ class BaseOption(BaseModel):
|
||||||
readonly: bool = False
|
readonly: bool = False
|
||||||
visible: Union[JSExpression, bool] = True
|
visible: Union[JSExpression, bool] = True
|
||||||
bind: Union[str, None] = None
|
bind: Union[str, None] = None
|
||||||
|
name: Union[str, None] = None # LEGACY (replaced by `id`)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
arbitrary_types_allowed = True
|
arbitrary_types_allowed = True
|
||||||
|
@ -297,6 +298,12 @@ class BaseOption(BaseModel):
|
||||||
del schema["description"]
|
del schema["description"]
|
||||||
schema["additionalProperties"] = False
|
schema["additionalProperties"] = False
|
||||||
|
|
||||||
|
# FIXME Legacy, is `name` still needed?
|
||||||
|
@validator("name", pre=True, always=True)
|
||||||
|
def apply_legacy_name(cls, value: Union[str, None], values: Values) -> str:
|
||||||
|
if value is None:
|
||||||
|
return values["id"]
|
||||||
|
return value
|
||||||
|
|
||||||
@validator("readonly", pre=True)
|
@validator("readonly", pre=True)
|
||||||
def can_be_readonly(cls, value: bool, values: Values) -> bool:
|
def can_be_readonly(cls, value: bool, values: Values) -> bool:
|
||||||
|
|
Loading…
Add table
Reference in a new issue