Re: mark form field as required in markup
You also do this like that: class CommentForm(forms.Form): name = forms.CharField( widget=forms.TextInput(attrs={'class':'special'})) url = forms.URLField() comment = forms.CharField( widget=forms.TextInput(attrs={'size':'40'})) 'class':'special' -- it marks your field with the class 'special' (example straight from Django documentation) http://www.djangoproject.com/documentation/newforms/#creating-custom-fields Best regards, l --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mark form field as required in markup
Well each field has and id that in your case here appears as 'id_age'. So you can attach a style sheet item to that field directly but that will not do anything for the whole row. If you just wanted to add something to the label like 'Age *" so the user can see that it's required that way, then use the label_suffix option when creating the form. If you want to customize the output of the form, you either have to write out the contents yourself (http://www.djangoproject.com/documentation/newforms/#complex-template-output), or create your own as_??? construct that give you what you want. Michael Trier blog.michaeltrier.com On Dec 7, 2007 5:27 AM, Frank 7200 <[EMAIL PROTECTED]> wrote: > Hi group, > another question. Is there a way how to pass an information to markup that a > form field is required? > > I have this form with one field, which is required (default value). > > class CustomForm(forms.Form ): > age = forms.ChoiceField(label='Age', choices=AGE_CHOICES) > > > {{ form.as_table}} > > > This is what appears in the markup > < > tr>Age: label> id="id_age"> > "1" selected="selected">0-3 > > I would need something like because I would like > to highlite the whole table row. Or at least > > How can I do that? > > Thanks for any advice, > Frank > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mark form field as required in markup
Hi group, another question. Is there a way how to pass an information to markup that a form field is required? I have this form with one field, which is required (default value). class CustomForm(forms.Form): age = forms.ChoiceField(label='Age', choices=AGE_CHOICES) {{ form.as_table}} This is what appears in the markup Age: 0-3 I would need something like because I would like to highlite the whole table row. Or at least How can I do that? Thanks for any advice, Frank --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---