Hi,

Le 12/03/2017 à 18:47, [email protected] a écrit :
> So I'm using a sequence to allow the user to input qr code data (using
> a scanner). There's a lot of variability in terms of exactly how many
> rows I'll need (enough so I don't want to have a precursor page
> specifying the number, as that would require the user to count items
> rather than just start scanning them.
>
> Initializing the form with X rows is trivial. Assuming the name of my
> sequence node is 'qrcodes', I can just render the form with
> form.render(appstruct={'qrcodes': ['']*X})

The Sequence widget has also a min_len attribute
http://docs.pylonsproject.org/projects/deform/en/latest/api.html#deform.widget.SequenceWidget

>
> However if I don't know ahead of time how many rows I'll need, the
> user will at some point have to add rows. How do I get one of the
> behaviours below (top-most is most preferred):-
>
> 1. As user scans one qrcode and presses 'enter', a new row is
> automatically created. This breaks 'enter-to-submit', but that's okay
> for this case.

You'll need to add some custom javascript code to perform this behaviour.

In the case your sequence items are only composed of the qrcode field,
something like this should work :

$('input[name=qrcode]').keypress(function(event){
|if(e.which ==13){
    deform.appendSequenceItem(this);
|        ||// prevent form submission|   
    return false;
}|
});


>
> 2. When user clicks on 'add new qr code' (the automatic javascript
> button which adds new items to the sequence, add a fixed number of
> rows (say 5) rather than just 1 as is currently the case.
>
> My fallback if none of the above works would probably be to pre-fill
> about 50 'empty' rows and just discard what I don't need. That would
> suck on mobile though, having to scroll all the way down, but as usage
> is primarily desktop in this case that won't matter too much.
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/aaed5bb0-f5de-48b7-a791-952a3f9a0298%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/aaed5bb0-f5de-48b7-a791-952a3f9a0298%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/f1705032-88ad-03bc-a317-1764064c586f%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to