I want to build forms in HTML by hands, without helpers from django
(like outputting field with label and etc), but I can't find one thing
- how I can get value from field (to select appropriate field in
radioselect, f.e.).
For example, RadioSelect provides unordered list with choices, but I
want to get fieldset - and can't select necessary field.
Thanks in advance.
--
Alexander
I'm unclear what you're asking here - you say you don't want to use
Django helpers, but they you ask about RadioSelect. Is your problem
with rendering the form, or with getting data from a submitted form?
Can you explain your problem another way, possibly with a more
complete example?
Yours,
Russ Magee %-)
> Can you explain your problem another way, possibly with a more
> complete example?
Ok, I'll try.
I want to enter HTML by hands, but can't determine which radio must be
selected. Form is built with form_for_instance, so it contains values.
Sorry if my description is unclear.
If you don't want to use a to output the form HTML that Django gives
you, you'll need to store some kind of value in the context to let you
know which radio button is selected.
Can I ask why, if you're using form_for_instance, you don't want to use
the form's HTML output as well?
Todd
This is what I was afraid. :)
> Can I ask why, if you're using form_for_instance, you don't want to use
> the form's HTML output as well?
Mmm... I'm using form_for_instance-derived form with many
modifications (Indeed, this is better than using form, written by
hands) - I love automatization. But my colleguaes, who are responsible
for HTML part, doesn't like django-generated forms - they want full
control.
--
Alexander
Yeah. Coworkers are a drag. ;-)
You do know that you can place the fields yourself, right?
If your form instance is called 'form' and has fields lastname and
firstname, you can put something like:
<table>
<tr class='polkadot'>
<td>{{ form.lastname }},</td><td>{{ form.firstname }}</td>
</tr>
</table>
in your template and have full control over the way the form looks.
You don't have to accept the default arrangement that Django gives by
default.
HTH,
Steve
Basic django forms give you full control over the placement of all the
fields. I wrote about a helper function that lets you access
individual radio buttons too, since otherwise you get all the
radiobuttons in one clump. See
http://fenron.blogspot.com/2007/06/custom-radio-field-rendering-with.html
.
Bill
I know that I can. ;) They want to have all this <input>s in HTML.
But, if I can't easily get value from field, they will use
{{ form.field }} notation. :D
--
Alexander
Thanks! I think this will help a lot!
--
Alexander