34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, FileField
|
|
from wtforms.fields import HiddenField
|
|
from wtforms.validators import DataRequired
|
|
from wtforms.widgets import ColorInput
|
|
from flask_wtf.file import FileAllowed
|
|
|
|
import re
|
|
from wtforms import ValidationError
|
|
|
|
# def hex_color_only(form, field):
|
|
# if not re.match(r'^#(?:[0-9a-fA-F]{3}){1,2}$', field.data):
|
|
# raise ValidationError('Debe ser un color hexadecimal válido (#RRGGBB o #RGB).')
|
|
|
|
class Carousel(FlaskForm):
|
|
# id = HiddenField() # Descomenta si lo necesitas
|
|
|
|
img = FileField(
|
|
'Imagen de fondo: ',
|
|
validators=[
|
|
DataRequired(),
|
|
FileAllowed(['jpg', 'jpeg', 'png', 'mp4'], 'Solo se permiten archivos .jpg, .png o .mp4')
|
|
]
|
|
)
|
|
|
|
|
|
bg_color = StringField('Color de fondo del texto: ', widget=ColorInput(), validators=[DataRequired()])
|
|
|
|
txt_color = StringField('Color del texto: ', widget=ColorInput(), validators=[DataRequired()])
|
|
|
|
txt = StringField('Texto: ', validators=[DataRequired()])
|
|
|
|
|