Django

Code

Ticket #5609 (closed: duplicate)

Opened 1 year ago

Last modified 2 months ago

newforms-admin: input fields do not regard field class

Reported by: anonymous Assigned to: brosner
Milestone: 1.0 beta Component: django.contrib.admin
Version: SVN Keywords: length input class
Cc: aloysius.prayitno@gmail.com, cmawebsite@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I tried the newforms-admin branch, and noticed input field length for a SmallInteger? field is wider than the trunk. Below is excerpt from the html source from newforms-admin branch and trunk. The one from newforms-admin is missing class=... etc.

newforms-admin:

<label for="id_treatment_visits" class="required">Treatment visits:</label>
<input type="text" name="treatment_visits" value="19" id="id_treatment_visits" />

trunk:

<label for="id_treatment_visits" class="required">Treatment visits:</label> 
<input type="text" id="id_treatment_visits" class="vSmallIntegerField required" name="treatment_visits" size="5" value="19" maxlength="5" />

Attachments

na2.diff (1.9 kB) - added by oggie_rob on 12/03/07 01:52:41.
Short version - most changes in trunk
trunk2.diff (29.1 kB) - added by oggie_rob on 12/03/07 01:55:14.
newforms changes to support newforms-admin setting up widgets correctly

Change History

09/28/07 04:12:41 changed by awi <aloysius.prayitno@gmail.com>

  • cc set to aloysius.prayitno@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

09/28/07 22:58:25 changed by Xian

  • owner changed from nobody to xian.
  • stage changed from Unreviewed to Accepted.

Thanks for reporting this, please let me know if any other field types are displaying incorrect widgets.

12/02/07 13:03:45 changed by oggie_rob

Working on this for the sprint. I'll be working off trunk and changing the db.models.fields.formfields() functions and probably some newforms.fields areas also. This will also result in changes to form_for_model/instance that I believe will be preferred (since things like class="required" is currently not being served up via form_for_model).

12/03/07 01:52:41 changed by oggie_rob

  • attachment na2.diff added.

Short version - most changes in trunk

12/03/07 01:55:14 changed by oggie_rob

  • attachment trunk2.diff added.

newforms changes to support newforms-admin setting up widgets correctly

12/03/07 02:12:14 changed by oggie_rob

This code is split two ways. Most of the changes I made were in newforms, so that form_for_model will return an appropriate widget. For example, a CharField model field will return a TextInput with class="required" (if blank=False), length="30" and maxlength according to the model. These changes then support features in newforms-admin pretty easily.

I updated some tests but ran out of time. Hopefully I can get to them later, but if the target branch is in question it would make sense to delay. Certainly there are plenty of tests that fail currently.

Finally one area that was a little funky... forms.Field uses a TextInput as a default widget, however the number of arguments in the __init__ function are rather small. It is a bit strange because typically you may want to set "size" and "maxlength" attributes of a TextField. Anything that extends Field misses out on those, however, and it is better to extend CharField. My feeling is that it would have been cleaner to not have a default widget.

12/10/07 10:52:23 changed by brosner

  • keywords changed from newforms-admin length input class to nfa-blocker length input class.

This breaks current admin functionality. I am tagging with nfa-blocker.

01/02/08 12:44:06 changed by Alex

  • has_patch set to 1.

06/16/08 10:46:19 changed by garcia_marc

  • milestone set to 1.0 alpha.

07/10/08 15:08:38 changed by brosner

Marked #7710 as a duplicate. We need to go through and find all the instances where there is a missing CSS class on a widget.

07/16/08 06:49:32 changed by anonymous

  • cc changed from aloysius.prayitno@gmail.com to aloysius.prayitno@gmail.com, cmawebsite@gmail.com.

07/19/08 10:56:35 changed by brosner

  • keywords changed from nfa-blocker length input class to length input class.
  • owner changed from xian to brosner.
  • status changed from new to assigned.
  • milestone changed from 1.0 alpha to 1.0 beta.

This ticket is going to require a bit of work. alpha will have to be released with this as a known issue in the admin. Bumping to 1.0-beta.

07/19/08 16:42:15 changed by Alex

  • version changed from newforms-admin to SVN.

08/08/08 13:06:35 changed by jacob

  • status changed from assigned to closed.
  • resolution set to duplicate.

#8163 has a better (looking, mostly) patch.


Add/Change #5609 (newforms-admin: input fields do not regard field class)




Change Properties
Action