mirror of https://git.48k.eu/ogcp
Add example image creation WTForms validator
Adds in a declarative way the validation of the image name form control when creating a partition image. This commit serves as an example of adding a predefined validator of the WTForms module. Custom validator may be added by creating a given function and appending it to the list of validators. See https://wtforms.readthedocs.io/en/2.3.x/validators/#custom-validatorsmulti-ogserver
parent
622f0bacbc
commit
e68eb7a3da
|
@ -2,6 +2,7 @@ from wtforms import (
|
|||
Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
|
||||
StringField, RadioField
|
||||
)
|
||||
from wtforms.validators import InputRequired
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_babel import _
|
||||
|
||||
|
@ -78,6 +79,7 @@ class ClientDetailsForm(FlaskForm):
|
|||
class ImageCreateForm(FlaskForm):
|
||||
ip = HiddenField()
|
||||
os = SelectField(label=_('OS'), choices=[])
|
||||
name = StringField(label=_('Image name'))
|
||||
name = StringField(label=_('Image name'),
|
||||
validators=[InputRequired()])
|
||||
description = StringField(label=_('Description'))
|
||||
create = SubmitField(label=_('Create'))
|
||||
|
|
Loading…
Reference in New Issue