[web2py] Re: nothing happens after custom form submission
Hi all, I got the solution. I changed the def myregister() function into def register(). Its working fine now. Previously it wasn't working, and the only thing I did new was just doing a clean from admin site menu. There is no point in clearing your browser history or restarting your shell. The clean helped me a lot. To howesc, you can use the normal tag and close it using {{form.custom.end}}. This is helpful when you have lot of customization in your form especially with css. And you get the hidden form fields generated automatically using the form.custom.end. On Friday, 4 January 2013 06:17:44 UTC+5:30, Anthony wrote: > > form.custom.end is what includes the hidden fields, and that has been > included in the code. > > Anthony > > On Thursday, January 3, 2013 6:59:20 PM UTC-5, howesc wrote: >> >> i don't see a {{=form.custom.begin}} in your view. this is required to >> output the hidden fields that web2py uses to validate the form submission. >> >> On Wednesday, January 2, 2013 8:03:47 AM UTC-8, ajith c t wrote: >>> >>> This is my form and controller function. My problem is nothing happens >>> (redirection) after the register button is clicked. >>> >>> def myregister(): >>> "select all roles greater than 1. root is always 1 " >>> print "in myregister" >>> >>> form = auth.register(next='index') >>> >>> print form.vars >>> return dict(form = form) >>> >>> the above is my custom "myregister()" function. >>> >>> {{extend 'layout.html'}} >>> This is the default/myregister.html template >>> >>> >> class="form-horizontal"> >>> >>> username: >>> {{=form.custom.widget.username}} >>> email: >>> {{=form.custom.widget.email}} >>> >>> password: >>> {{=form.custom.widget.password}} >>> confirm password: >>> {{=form.custom.widget.password_two}} >>> >>> account_id: >>> {{=form.custom.widget.account_id}} >>> >>> role_id: >>> {{=form.custom.widget.role_id}} >>> >>> {{=form.custom.submit}} >>> >>> >>> {{=form.custom.end}} >>> {{pass}} >>> >>> above code is my custom register view "myregister.html" >>> >>> i am using auth_user table after adding extra fields: >>> >>> auth.settings.extra_fields['auth_user']= [ >>> Field('account_id', 'integer', notnull=True), # (`account_id` >>> int(11) NOT NULL,) >>> Field('organisation_id', 'integer'), # (`organisation_id` >>> int(11) DEFAULT '0',) >>> Field('role_id', 'integer', notnull=True, requires = IS_IN_SET([(2, >>> 'admin'), (3, 'merchant'), (4, 'guest')])), # (`role_id` int(11) NOT NULL >>> DEFAULT '0',) >>> Field('username', 'string'), # (`username` varchar(64) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('telephone', 'string'), # (`telephone` >>> varchar(16) COLLATE utf8_bin DEFAULT NULL,) >>> Field('mobile', 'string'), # (`mobile` varchar(16) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('gender', 'string'), # (`gender` char(1) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('about', 'text'),# (`about` text COLLATE >>> utf8_bin,) >>> Field('addr_1', 'string'), # (`addr_1` varchar(128) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('addr_2', 'string'), # (`addr_2` varchar(128) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('addr_3', 'string'), # (`addr_3` varchar(128) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('city', 'string'), # (`city` varchar(64) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('region', 'string'), # (`region` varchar(32) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('country', 'string'),# (`country` char(2) >>> COLLATE utf8_bin DEFAULT NULL,) >>> Field('post_code', 'string'), # (`post_code` >>> varchar(16) COLLATE utf8_bin DEFAULT NULL,) >>> Field('is_email_public', 'integer'), # (`is_email_public` >>> smallint(6) DEFAULT NULL,) >>> Field('is_acct_active', 'integer'),# (`is_acct_active` >>> smallint(6) DEFAULT NULL,) >>> Field('security_question', 'integer'), # (`security_question` >>> smallint(6) DEFAULT NULL,) >>> Field('security_answer', 'string'),# (`security_answer` >>> varchar(128) COLLATE utf8_bin DEFAULT NULL,) >>> Field('date_created', 'datetime'), # (`date_created` >>> datetime DEFAULT NULL,) >>> Field('created_by', 'integer'),# (`created_by` int(11) >>> DEFAULT NULL,) >>> Field('last_updated', 'datetime'), # (`last_updated` >>> datetime DEFAULT NULL,) >>> Field('updated_by', 'integer') >>> >>> ] >>> >>> auth.settings.registration_requires_verification = False >>> auth.settings.registration_requires_approval = False >>> auth.settings.reset_password_requires_verification = True >>> auth.settings.login_after_registration = True >>> auth.settings.create_user_groups = F
[web2py] Re: nothing happens after custom form submission
form.custom.end is what includes the hidden fields, and that has been included in the code. Anthony On Thursday, January 3, 2013 6:59:20 PM UTC-5, howesc wrote: > > i don't see a {{=form.custom.begin}} in your view. this is required to > output the hidden fields that web2py uses to validate the form submission. > > On Wednesday, January 2, 2013 8:03:47 AM UTC-8, ajith c t wrote: >> >> This is my form and controller function. My problem is nothing happens >> (redirection) after the register button is clicked. >> >> def myregister(): >> "select all roles greater than 1. root is always 1 " >> print "in myregister" >> >> form = auth.register(next='index') >> >> print form.vars >> return dict(form = form) >> >> the above is my custom "myregister()" function. >> >> {{extend 'layout.html'}} >> This is the default/myregister.html template >> >> > class="form-horizontal"> >> >> username: >> {{=form.custom.widget.username}} >> email: >> {{=form.custom.widget.email}} >> >> password: >> {{=form.custom.widget.password}} >> confirm password: >> {{=form.custom.widget.password_two}} >> >> account_id: >> {{=form.custom.widget.account_id}} >> >> role_id: >> {{=form.custom.widget.role_id}} >> >> {{=form.custom.submit}} >> >> >> {{=form.custom.end}} >> {{pass}} >> >> above code is my custom register view "myregister.html" >> >> i am using auth_user table after adding extra fields: >> >> auth.settings.extra_fields['auth_user']= [ >> Field('account_id', 'integer', notnull=True), # (`account_id` >> int(11) NOT NULL,) >> Field('organisation_id', 'integer'), # (`organisation_id` >> int(11) DEFAULT '0',) >> Field('role_id', 'integer', notnull=True, requires = IS_IN_SET([(2, >> 'admin'), (3, 'merchant'), (4, 'guest')])), # (`role_id` int(11) NOT NULL >> DEFAULT '0',) >> Field('username', 'string'), # (`username` varchar(64) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('telephone', 'string'), # (`telephone` varchar(16) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('mobile', 'string'), # (`mobile` varchar(16) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('gender', 'string'), # (`gender` char(1) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('about', 'text'),# (`about` text COLLATE >> utf8_bin,) >> Field('addr_1', 'string'), # (`addr_1` varchar(128) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('addr_2', 'string'), # (`addr_2` varchar(128) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('addr_3', 'string'), # (`addr_3` varchar(128) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('city', 'string'), # (`city` varchar(64) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('region', 'string'), # (`region` varchar(32) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('country', 'string'),# (`country` char(2) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('post_code', 'string'), # (`post_code` varchar(16) >> COLLATE utf8_bin DEFAULT NULL,) >> Field('is_email_public', 'integer'), # (`is_email_public` >> smallint(6) DEFAULT NULL,) >> Field('is_acct_active', 'integer'),# (`is_acct_active` >> smallint(6) DEFAULT NULL,) >> Field('security_question', 'integer'), # (`security_question` >> smallint(6) DEFAULT NULL,) >> Field('security_answer', 'string'),# (`security_answer` >> varchar(128) COLLATE utf8_bin DEFAULT NULL,) >> Field('date_created', 'datetime'), # (`date_created` datetime >> DEFAULT NULL,) >> Field('created_by', 'integer'),# (`created_by` int(11) >> DEFAULT NULL,) >> Field('last_updated', 'datetime'), # (`last_updated` datetime >> DEFAULT NULL,) >> Field('updated_by', 'integer') >> >> ] >> >> auth.settings.registration_requires_verification = False >> auth.settings.registration_requires_approval = False >> auth.settings.reset_password_requires_verification = True >> auth.settings.login_after_registration = True >> auth.settings.create_user_groups = False >> >> def onaccept(form): # form accepted >> auth.add_membership(form.vars.role_id, form.vars.id) >> >> auth.settings.register_onaccept.append(onaccept) >> >> >> I dont know what is going wrong. >> I have gone through similar questions in this forum but could solve this. >> any help would be appreciated >> > --
[web2py] Re: nothing happens after custom form submission
i don't see a {{=form.custom.begin}} in your view. this is required to output the hidden fields that web2py uses to validate the form submission. On Wednesday, January 2, 2013 8:03:47 AM UTC-8, ajith c t wrote: > > This is my form and controller function. My problem is nothing happens > (redirection) after the register button is clicked. > > def myregister(): > "select all roles greater than 1. root is always 1 " > print "in myregister" > > form = auth.register(next='index') > > print form.vars > return dict(form = form) > > the above is my custom "myregister()" function. > > {{extend 'layout.html'}} > This is the default/myregister.html template > > class="form-horizontal"> > > username: > {{=form.custom.widget.username}} > email: > {{=form.custom.widget.email}} > > password: > {{=form.custom.widget.password}} > confirm password: > {{=form.custom.widget.password_two}} > > account_id: > {{=form.custom.widget.account_id}} > > role_id: > {{=form.custom.widget.role_id}} > > {{=form.custom.submit}} > > > {{=form.custom.end}} > {{pass}} > > above code is my custom register view "myregister.html" > > i am using auth_user table after adding extra fields: > > auth.settings.extra_fields['auth_user']= [ > Field('account_id', 'integer', notnull=True), # (`account_id` int(11) > NOT NULL,) > Field('organisation_id', 'integer'), # (`organisation_id` > int(11) DEFAULT '0',) > Field('role_id', 'integer', notnull=True, requires = IS_IN_SET([(2, > 'admin'), (3, 'merchant'), (4, 'guest')])), # (`role_id` int(11) NOT NULL > DEFAULT '0',) > Field('username', 'string'), # (`username` varchar(64) > COLLATE utf8_bin DEFAULT NULL,) > Field('telephone', 'string'), # (`telephone` varchar(16) > COLLATE utf8_bin DEFAULT NULL,) > Field('mobile', 'string'), # (`mobile` varchar(16) > COLLATE utf8_bin DEFAULT NULL,) > Field('gender', 'string'), # (`gender` char(1) COLLATE > utf8_bin DEFAULT NULL,) > Field('about', 'text'),# (`about` text COLLATE > utf8_bin,) > Field('addr_1', 'string'), # (`addr_1` varchar(128) > COLLATE utf8_bin DEFAULT NULL,) > Field('addr_2', 'string'), # (`addr_2` varchar(128) > COLLATE utf8_bin DEFAULT NULL,) > Field('addr_3', 'string'), # (`addr_3` varchar(128) > COLLATE utf8_bin DEFAULT NULL,) > Field('city', 'string'), # (`city` varchar(64) > COLLATE utf8_bin DEFAULT NULL,) > Field('region', 'string'), # (`region` varchar(32) > COLLATE utf8_bin DEFAULT NULL,) > Field('country', 'string'),# (`country` char(2) > COLLATE utf8_bin DEFAULT NULL,) > Field('post_code', 'string'), # (`post_code` varchar(16) > COLLATE utf8_bin DEFAULT NULL,) > Field('is_email_public', 'integer'), # (`is_email_public` > smallint(6) DEFAULT NULL,) > Field('is_acct_active', 'integer'),# (`is_acct_active` > smallint(6) DEFAULT NULL,) > Field('security_question', 'integer'), # (`security_question` > smallint(6) DEFAULT NULL,) > Field('security_answer', 'string'),# (`security_answer` > varchar(128) COLLATE utf8_bin DEFAULT NULL,) > Field('date_created', 'datetime'), # (`date_created` datetime > DEFAULT NULL,) > Field('created_by', 'integer'),# (`created_by` int(11) > DEFAULT NULL,) > Field('last_updated', 'datetime'), # (`last_updated` datetime > DEFAULT NULL,) > Field('updated_by', 'integer') > > ] > > auth.settings.registration_requires_verification = False > auth.settings.registration_requires_approval = False > auth.settings.reset_password_requires_verification = True > auth.settings.login_after_registration = True > auth.settings.create_user_groups = False > > def onaccept(form): # form accepted > auth.add_membership(form.vars.role_id, form.vars.id) > > auth.settings.register_onaccept.append(onaccept) > > > I dont know what is going wrong. > I have gone through similar questions in this forum but could solve this. > any help would be appreciated > --