mirror of https://git.48k.eu/ogcp
forms: ensure ip and mac are not empty in client add form
Use the WTForms validator InputRequired to check the field and disable the submit button if either the IP or MAC fields have no contents.master
parent
cf6794d7c8
commit
43e3346a4a
|
@ -122,8 +122,10 @@ class FolderForm(FlaskForm):
|
|||
class ClientDetailsForm(FlaskForm):
|
||||
server = HiddenField()
|
||||
name = StringField(label=_l('Name'))
|
||||
ip = StringField(label=_l('IP'))
|
||||
mac = StringField(label=_l('MAC'))
|
||||
ip = StringField(label=_l('IP'),
|
||||
validators=[InputRequired()])
|
||||
mac = StringField(label=_l('MAC'),
|
||||
validators=[InputRequired()])
|
||||
serial_number = StringField(label=_l('Serial Number'))
|
||||
livedir = SelectField(label=_l('ogLive'),
|
||||
choices=[('ogLive', 'Default'),])
|
||||
|
|
|
@ -1472,6 +1472,11 @@ def action_folder_add_post():
|
|||
def action_client_add():
|
||||
form = ClientDetailsForm(request.form)
|
||||
if request.method == 'POST':
|
||||
|
||||
if not form.validate():
|
||||
flash(form.errors, category='error')
|
||||
return redirect(url_for('servers'))
|
||||
|
||||
payload = {"boot": form.boot.data,
|
||||
"ip": form.ip.data,
|
||||
"livedir": form.livedir.data,
|
||||
|
|
Loading…
Reference in New Issue