form = t2.create(db.function_test,next='test_case/%s'%t2.id)
;-)
On Jan 21, 5:38 pm, jlegler <[email protected]> wrote:
> Okay everyone, I am completely new to web2py and have what I hope is a
> simple question. I have been hung up for days trying to build a
> custom form that, upon submittal, will reload the page it is on
> including the REST value at the end of the URL. I am generating a
> custom form in Python and passing it to the view. Basically, I want
> to submit a form on a page with the URL of:
>
> http://example/VSE/default/test_case/1
>
> and cause it to reload that exact URL upon submittal.
>
> The problem I am having is that upon submittal, it goes to:
>
> http://example/VSE/default/test_case
>
> which has no data in it because I am using that variable (which is
> t2.id) to choose what data to show and that variable is missing upon
> submittal. I hope to eventually have multiple forms on the page and I
> have some scaffolding in place (modify_form); however, I haven't even
> tried to get any of that to work until I can get the create_form
> function to work. You can probably ignore it; however, I figured I
> would include it in case someone notices something in it that is
> causing the problem in the first form. If I could get the top one
> (create_form) to post and then refresh the page instead of jumping to
> the base controller page I would be pretty excited. Anyone have any
> ideas? I am posting the controller and a function from the model
> below. Please forgive the hideous code. I am appropriately
> embarrassed by it; however it is a work in progress and I haven't gone
> back to clean it up yet and I am really stuck here. All of it works
> other than the page it goes to upon submittal so any ideas would be
> appreciated. Thanks for any help that anyone can provide.
>
> #Controller Code
> @t2.requires_login(next='login')
> def test_case():
> form = t2.create(db.function_test)
> create_form = FORM(TABLE(THEAD(TR('ID', 'Functionality', 'Task',
> 'Expected Result', 'Test
> Status',
> 'Regression', 'Comments', 'AC*',
> 'AT**',
> _class='header')),
> (TR(DIV('*',
> _class='id'),
> TEXTAREA(_name='functionality',
> _class='functionality'),
> TEXTAREA(_name='task',
> _class='task'),
> TEXTAREA(_name='expected_result',
> _class='expected_result'),
> SELECT(test_status_menu('Not Run'),
> _name='test_status',
> _class='test_status'),
> TEXTAREA(_name='comments',
> _class='comments'),
> TEXTAREA(_name='regression',
> _class='regression'),
> INPUT(_type='checkbox',
> _name='affects_clients'),
> INPUT(_type='checkbox',
>
> _name='client_acceptance_test'),
> INPUT(_type='hidden',
> _name='test_case',
> _value=t2.id),
> custom(db.function_test))),
> _class='function_tests',
> _cellspacing='0'),
> INPUT(_type='submit',
> _action='',
> _method='post',
> _value='Create Function Test'))
>
> function_tests = []
> for i in db(db.function_test.test_case==t2.id).select():
> function_tests.append(
> FORM(TD(TR(DIV(i.id,
> _class='id'),
> TEXTAREA(_name='functionality_'+str(i.id),
> value=i.functionality,
> _class='functionality'),
> TEXTAREA(_name='task_'+str(i.id),
> value=i.task,
> _class='task'),
> TEXTAREA(_name='expected_result_'+str(i.id),
> value=i.expected_result,
> _class='expected_result'),
> SELECT(test_status_menu(i.test_status),
> _name='test_status_'+str(i.id),
> _class='test_status'),
> TEXTAREA(_name='comments_'+str(i.id),
> value=i.comments, _class='comments'),
> TEXTAREA(_name='regression_'+str(i.id),
> value=i.regression,
> _class='regression'),
> INPUT(_type='checkbox',
> _name='affects_clients_'+str(i.id),
> value=i.affects_clients),
> INPUT(_type='checkbox',
> _name='client_acceptance_test_'+str
> (i.id),
> value=i.client_acceptance_test)))))
>
> head = THEAD(TR('ID', 'Functionality', 'Task', 'Expected Result',
> 'Test Status', 'Regression', 'Comments', 'AC*',
> 'AT**',
> _class='header'))
>
> modify_form = DIV(TABLE(head,
> function_tests,
> _class='function_tests',
> _cellspacing='0'),
> P('*AC = Affects Clients, ' +
> '**AT = Client Acceptance Test',
> _class='legend'))
>
> return dict(modify_form=modify_form, create_form=create_form)
>
> Model:
> def custom(table):
> """
> Allows me to build custom tables instead of the built in ones by
> returning
> a table with two hidden fields; one with the formname and one with
> the
> formkey.
> """
> import uuid
> formkey=session['_formkey[%s]' % table]=str(uuid.uuid4())
> return TD(INPUT(_name='_formname', _value=str(table),
> _type='hidden'),
> INPUT(_name='_formkey', _value=formkey,
> _type='hidden'))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---