Code

Opened 3 years ago

Closed 3 years ago

#16305 closed New feature (wontfix)

Create a form.TextField() form field

Reported by: rich@… Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords: forms, default
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

To create a Text Field in a model, one calls:

models.TextField()

yet to create a TextField in a form, one must:

forms.CharField(max_length=200, widget=forms.TextInput({}))

Also, a ModelForm can bind to a model with a TextField by creating a CharField with a TextInput widget, like above.

Why not make a forms.TextField as a shortcut (simply a CharField with a different default widget).

The key benefit here would simply to make the Forms and Models symmetrical. As a developer, using a TextField in one place and then a CharField/widgetTextInput in another place to create the same effect seems very counter-intuitive, especially when the fix is so simple.

What do you think?

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Sorry, all instance of TextInput above should read Textarea.

comment:2 Changed 3 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

This suggestion misses the reason why the distinction exists in the first place. The form layer deals with data. The widget layer deals with presentation. The decision to use Textarea or a TextInput is purely presentational -- it has no effect on the data handling.

This is a situation where we'd gain a minor simplification for a limit set of use cases, in exchange for obscuring the distinction between the two layers. Marking wontfix for this reason.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.