sei-ec-remote / team-project-issues

0 stars 0 forks source link

Capitalizing Form Names #171

Closed jpineda48 closed 1 year ago

jpineda48 commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

I was hoping to have some help creating a function that capitalized the first and last name of a form input.

What is the problem you are trying to solve? I was hoping to have some help creating a function that capitalized the first and last name of a form input.

Expected behavior A clear and concise description of what you expected to happen.

using the title() or capitalize() function to capitalize the first and lastname of a form input.

What is the actual behavior? A clear and concise description of what actually happened.

Not able to render any type of behavior

Post any code you think might be relevant (one fenced block per file) BIRTHDAY CREATE VIEW


class BirthdayCreate(LoginRequiredMixin, CreateView):
  model = Birthday
  fields = ['first_name', 'last_name', 'date', 'relationship', 'address', 'phone_number', 'email', 'delivery_method', 'alert']
  # fields = '__all__'

  def form_valid(self, form):
    form.instance.user = self.request.user 
    return super().form_valid(form)

  def capitalize(self, form):
    first_name=form.instance.first_name
    first_name.capitalize()

What is your best guess as to the source of the problem?

Some how I need to extract the words i need form the form.

What things have you already tried to solve the problem?

  def capitalize(self, form):
    first_name=form.instance.first_name
    first_name.capitalize()
  def capitalize(self, form):
    form.instance.first_name = first_name.capitalize(

Additional context Add any other context about the problem here.

Paste a link to your repository here

asands94 commented 1 year ago

I would try adding the capitalization code you have as part of the form_valid method instead of it being its own method