Thanks Anthony. That makes sense. Regards Johann
On 30 January 2014 16:37, Anthony <abasta...@gmail.com> wrote: > Looks like you've got survey_id as a variable in your URL query string, so > it will end up in request.get_vars. When you edit a record, the form also > includes a survey_id variable, which will end up in request.post_vars. > request.vars is a combination of get_vars and post_vars, so if they both > contain a variable with the same name, when merged into request.vars, those > values get combined into a list. > > To avoid the problem, just use request.get_vars.survey_id in your code (or > use a variable name other than survey_id in your query string). > > Anthony > > > On Thursday, January 30, 2014 8:08:29 AM UTC-5, Johann Spies wrote: >> >> >> In the following controller when edit a row and submit, >> request.vars.survey_id changes from '3' to ['3', '3'] >> but not if I click on 'Back' without editing. Why? >> >> I had to use the following workaround: >> >> survey_id = request.vars.survey_id[0] if isinstance(survey_id, list) >> else request.vars.survey_id >> >> >> @auth.requires_login() >> def edit_survey(): >> response.view = 'default/survey_create.html' >> survey_id = request.vars.survey_id >> if isinstance(survey_id, list): >> survey_id = survey_id[0] >> survey = db.survey[survey_id] >> db.questions.id.readable = False >> if survey_id: >> query = db.questions.survey_id== survey_id >> fields = [db.questions.question_number, >> db.questions.question,db.questions.answer_type, >> db.questions.id] >> questions = SQLFORM.grid(query, >> editable = True, >> deletable = True, >> create = True, >> searchable = False, >> maxtextlength = 100, >> orderby=db.questions.question_number) >> header = H3(T('%s for editing' % db.survey[survey_id].name)) >> else: >> header = H3(T('No valid survey selected')) >> form = '' >> return dict(header = header, form = questions) >> >> Regards >> Johann >> > -- > 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 web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.