Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FormElementStructure:
- """
- Класс для установки настроек формы
- """
- element_list = {
- 'password': '<input type="password" name="%s" placeholder="%s" class="%s" %s>',
- '_file': '<input type="file" name="%s" placeholder="%s" class="%s" %s>',
- 'text': '<input type="text" name="%s" placeholder="%s class="%s" %s>',
- 'email': '<input type="email" name="%s" placeholder="%s" class="%s" %s>',
- 'number': '<input type="number" name="%s" min="0" max="9999999" placeholder="%s" class="%s" %s>',
- 'url': '<input type="url" name="%s" placeholder="%s" class="%s" %s>',
- 'phone': '<input type="tel" name="%s" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" placeholder="%s" class="%s" %s>',
- }
- @staticmethod
- def form_element(
- cls,
- name: str,
- type_form: str,
- class_element: str,
- placeholder: str,
- attrs: dict = None,
- ) -> str:
- """_summary_
- Args:
- name (str): _description_
- type_form (str): _description_
- class_element (str): _description_
- placeholder (str): _description_
- attrs (dict, optional): _description_. Defaults to None.
- Returns:
- str: _description_
- """
- return cls.element_list[type_form].format(
- name,
- placeholder,
- class_element,
- ' '.join([f'data-{item}={attrs[item]}' for item in attrs]),
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement