from django.forms import ModelForm, Textarea, TextInput
from django.utils.translation import gettext_lazy as _
from .models import BinhLuan


class BinhLuanForm(ModelForm):

  class Meta:

    model = BinhLuan
    fields = ["ten_nguoi_dang", "thong_tin_lien_he", "tieu_de", "noi_dung"]

    # Placeholder bọc _() để dịch theo ngôn ngữ trang (trước đây cứng tiếng Việt
    # nên bản /en/ vẫn hiện "Tên của bạn", "Bình luận"... lẫn với nhãn tiếng Anh).
    widgets = {
      "ten_nguoi_dang": TextInput(attrs={
        "class": "form-control form-control-lg",
        "placeholder": _("Tên của bạn"),
        "name": "ten",
        "required": True
      }),
      "thong_tin_lien_he": TextInput(attrs={
        "class": "form-control form-control-lg",
        "placeholder": _("Email/SĐT"),
        "name": "thong_tin_lien_he",
        "required": True
      }),
      "tieu_de": TextInput(attrs={
        "class": "form-control form-control-lg",
        "placeholder": _("Tiêu đề"),
        "name": "tieu_de",
        "required": True
      }),
      "noi_dung": Textarea(attrs={
        "class": "form-control form-control-lg",
        "row": "7",
        "placeholder": _("Bình luận"),
        "name": "noi_dung",
        "required": True,
      }),
    }
