Hi,
I think this is one that a few people have put on the forum but i don't think
it's been answered properly (or I've just missed it).
Basically, I would like a form, controls determined by my choosing by the
fields (initialisation).
ideally in pseudo code something like this:
def createform():
form = define custom form
if form.initialising:
set values to the fields, for selects, set the list of entries and the
current selection (i could get this from the database, various tables or
compute them)
elif form.accepts(request, session):
# passed simple validation
# maybe now do some other cross checking
if extra_checks_ok:
save to db maybe
else:
flash issue and reject
elif form.errors:
# deal with errors
return dict(form=form)
It would make creating forms much faster and allow for greater control.
I don't care if it's FORM of SQLFORM.factory, mainly interested it getting it
working.
The following is a simplified version of what i need. (I don't really want
to use defaults, plus i don't think it will solve the issue).
This has been frustrating me for some time, thinking I have missed something,
but I'm beginning to think it's a feature needed.
def testform():
form=FORM('Phone Number:',
INPUT(_name='phone', type='string', requires=IS_NOT_EMPTY()),
INPUT(_type='submit'))
if form.accepts(request,session):
response.flash = 'form accepted'
db.config.update_or_insert(
db.config.type=='SMS_NUMBER',
type='SMS_NUMBER',
txt=form.vars.phone
)
# The new number will now show in the input box on the screen as well.
elif form.errors:
response.flash = 'form has errors'
else:
record = db(db.config.type=="SMS_NUMBER").select()
smsNumber = record.value if record else ''
form.var = smsNumber
response.flash = 'Please fill in the form'
return dict(form=form)
Thanks
Den
--
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.