I found it necessary to create a manual form, but I'd like to add back the 
cool default jQuery effects to report on validation errors for the one 
input field.

Is there a quick way to access and pass these jQuery effects back in to my 
manual form?

Here's the db definition:

db = DAL('mysql://user:password@localhost/1test', pool_size=2)
db.define_table('vendors',
    Field('vendor_id', 'integer', length=4, required=True, unique=True,notnull
=True, label='Vendor ID', 
           requires=[IS_NOT_EMPTY(), 
                     IS_INT_IN_RANGE(100,9999, error_message='Number Out Of 
Range')]),
    Field('vendor_name', 'string', length=25, required=True, unique=True,notnull
=True, label='Vendor Name', 
           requires=[IS_NOT_EMPTY(), 
                     IS_LENGTH(minsize=1,maxsize=25),
                     IS_MATCH('^[a-zA-Z0-9\s]+$', error_message='Bad Vendor 
Name')]),
    format='%(vendor_id)s %(vendor_name)s',
    migrate=True)
db.vendors.id.readable = db.vendors.id.writable = False
db.vendors.vendor_id.readable = False




Here's the relevant controller:

def manual_form():
    newid = db.executesql('select max(vendor_id) as last from vendors',as_dict
=True)
    t = (newid[0]['last'] + 1)
    form = SQLFORM(db.vendors)
    if form.process(session=None, formname='manual').accepted:
        redirect(URL('manual_form'))
        response.flash = 'Manual Form Accepted'
    elif form.errors:
        response.flash = 'Manual Form Has Errors'
    else:
        response.flash = 'Please Enter A Vendor Name'
    return locals()



And finally here's the manual_form.html:


{{extend 'layout.html'}}
<form action="#" enctype="multipart/form-data" method="post">
<UL>
    <LI>New Vendor ID: <input type="hidden" name="vendor_id", value="{{=t}}" 
>{{=t}}</LI>
    <LI>New Vendor Name: <input name="vendor_name" /></LI>
</UL>
    <input type="submit" value="Submit" />
    <input type="hidden" name="_formname" value="manual" />
</form>



The reason I made the manual form is because I want the new vendor_id to 
always be the last vendor_id + 1. I'd use an autoincrement field for 
vendor_id, but I don't want to have gaps if any of them are ever deleted. 
Now that that part's working, I'd like to have the validators back, but I 
know very little about Javascript in general. Therefore, I was hoping that 
there's some easy web2py hooks to the jQuery effects that I can grab and 
put back into this or future forms.

Sincere thanks for any assistance.





-- 

--- 
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/groups/opt_out.

Reply via email to