populate form in view

66 views
Skip to first unread message

Iancic Bogdan

unread,
Aug 25, 2015, 8:16:49 AM8/25/15
to web2py-users
I want to populate a form, besides the input that the user inserts.

This is the code from view:
<script>
        var MattsPublicKeyString = cryptico.publicKeyString(MattsRSAkey);

        print("Matt's public key string:");
        print(MattsPublicKeyString);
</script>
<script type=t"text/javascript">
        document.onload = function(){updateText()};

        function updateText() {
         document.certificate_request_public_key__row.populateme.value =
MattsPublicKeyString;
       }

<h1>{{=T('New Certificate Signing Request')}}</h1>
{{=text}}
<br/>
{{=form}}

The key that I want to insert in the form is correctly displayed but it isint' inserted in the database. What am I doing wrong?

Jim S

unread,
Aug 25, 2015, 8:51:27 AM8/25/15
to web2py-users
Can we see the form definition from your controller?

-Jim

Iancic Bogdan

unread,
Aug 25, 2015, 8:52:53 AM8/25/15
to web2py-users
sure

form = SQLFORM(db.certificate_request).process()
    if form.accepted:
        response.flash = 'new CSR registered'
        redirect(URL('customerArea','index'))

Jim S

unread,
Aug 26, 2015, 9:34:31 AM8/26/15
to web2py-users
I'm confused by the use of .process() at the end of your SQLFORM instantiation.

Instead, I would do this:

form = SQLFORM(db.certificate_request)

if form.process().accepted:
    response.flash = 'new CSR registered'
    redirect(URL('customerArea', 'index')

Hope that helps.

-Jim

Anthony

unread,
Aug 26, 2015, 11:07:43 AM8/26/15
to web2py-users
There's nothing wrong with calling .process() when the form is first defined. Your code is exactly equivalent to the original.

Anthony

Jim Steil

unread,
Aug 26, 2015, 11:21:45 AM8/26/15
to web...@googlegroups.com
Thanks for the correction Anthony, I didn't know that.

-Jim

On Wed, Aug 26, 2015 at 10:07 AM, Anthony <abas...@gmail.com> wrote:
There's nothing wrong with calling .process() when the form is first defined. Your code is exactly equivalent to the original.

Anthony

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/lvimBCvBDl0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages