Your form doesn't save because you do not seems to have create a full
functionning log_results form controller... You miss :


    if form.process().accepted:
        session.flash = 'form accepted'
        redirect(URL('next'))
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'


Here the doc :
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Forms-and-redirection

I am not sure what you are trying to do in your custom form though, kind of
want multiple input fields for points_set reference depending of the number
of n_sets??

I am not sure it would work that way... It may seems to work, but it surely
not work properly as each input you create will be "merge" as one insert at
the end in the database and depends what you try to achieve the inputed
values will not maybe represent the proper semantic you want as they me get
insert in differents order than you input them for instance...


I think you should try to explain us what you want to achieve in term of
functionality and not try to get technical answer as it may turns that
there is a better/proper way to do what you try to do, but without knowing
it we will provide wrong direction to you in our answer...

Richard





On Mon, Oct 31, 2016 at 11:26 AM, Nicola Clementel <
[email protected]> wrote:

> Hi,
>
> I am trying to create a dynamic custom form (see below), but I have
> several problems:
>
> 1) the form doesn't update if the value in n_sets is changed: the
> request.vars.n_set is only called once and it refers to the previous form
> submission
> 2) submit doesn't save to the database: I think that the problem might be
> connected with the fact that points_set is a 'list:integer' (it is this way
> because the number of sets is variable)
> 3) I am not able to remove the +- button: I don't need them since the
> number of list items is defined by the n_sets value
>
> Any suggestion?
>
> Thanks!
>
> db.define_table('points',
>     Field('n_sets','integer',default=2,requires=(IS_NOT_EMPTY(),
> IS_INT_IN_RANGE(1,10))),
>     Field('points_set','list:integer'))
>
>
> def log_results():
>     form = SQLFORM(db.points)
> return dict(form=form)
>
>
> {{=form.custom.begin}}
>     Sets: <div>{{=form.custom.widget.n_sets}}</div>
>
>     {{for i in range(int(request.vars.n_sets)):}}
>         Points set {{=i+1}}: <div>{{=form.custom.widget.points_set}}</div>
>     {{pass}}
>
>     {{=form.custom.submit}}
> {{=form.custom.end}}
>
>
> <https://lh3.googleusercontent.com/-G6rSj2CoWqE/WBdZpFl4scI/AAAAAAAAG0s/aZ4Tc_gOR6cYttU-n5uaedxVYsIuQfezQCLcB/s1600/Screen%2BShot%2B2016-10-31%2Bat%2B16.46.48.png>
>
>
> --
> 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 the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to