Hi Craig,
Your solution made me think a bit more and the fog finaly dissappeared. The
problem is with the template, it should look like:
<div id="form">
${form.display(value=value)}
</div>
and then you can pre-fill values of the fields sending a dictionary like:
values = {'ident': ident, 'other_field': 'other_value'}
The way template originaly looked like I could have called it like:
return(dict(page='new', form=self.FileForm, title=ident, ident=ident))
but the new version is certainly better.
Puska
On Friday, December 27, 2013 2:25:17 PM UTC+1, puska wrote:
>
> Hi everyone,
>
> I am trying to create a form which TextField shoud be populated with a
> default value.
>
> My controller looks like:
>
> class FileController(BaseController):
> class FileForm(twf.Form):
> class child(twf.TableLayout):
> ident = twf.TextField()
> input_file = twf.FileField(label='Input file: ')
> action = lurl('./process_file')
>
> @expose('amandmani.templates.form2', inherit=True)
> def new(self, ident, *args, **kw):
> value = {
> 'ident': ident,
> }
> return dict(page='new', form=self.FileForm, title=ident,
> value=value)
>
> and is rendered by the following template snippet:
>
> <div id="form">
> ${form.display(value=dict(title='default title'))}
> </div>
>
> but I can't get ident field to show value to be passed to function new().
>
> The URL looks like http://localhost:8080/file/new/15
>
> I can tell that 15 gets passed to new() because it shows in the title, but
> ident field remains empty.
>
> Any help would be greatly appreciated.
>
> Puska
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.