Hard to say what's going on without seeing the real code. The code you have
shown does not do what you say -- if you enter a non-IPV4 address, the form
is not accepted, and instead it produces an error message as expected.
Anthony
On Thursday, February 27, 2014 4:45:05 PM UTC-5, Austin Taylor wrote:
>
> Anthony,
>
> I have another function in the code that redirects the page, but that
> should only work if form.process().accepted works.
>
> After if form.process().accepted:
> I have it run through a long list of code and at the very end it goes
> into a function defined in my models.py. The function writes all the values
> to a dictionary and then redirects to the results.html page which displays
> properly. The problem is the form.process().accepted isn't performing
> validation. I can click the submit button and it will redirect me to a
> blank page and it says "None". However if I type in a proper value it works
> great. Shouldn't form.process().accepted only go through if there were no
> processing errors? a blank field is not valid, but it still processes.
>
> On Thursday, February 27, 2014 2:00:47 PM UTC-5, Anthony wrote:
>>
>> Using your exact code, I cannot replicate the behavior you observe. Can
>> you show the view code? Is there any other relevant code that might be
>> doing a redirect somewhere?
>>
>> On Thursday, February 27, 2014 12:24:14 PM UTC-5, Austin Taylor wrote:
>>>
>>> Also want to add that the function takes me to a page that says None. If
>>> the IP I type in the input field meets an if condition it works properly,
>>> but if its any kind of character, or an IP that doesn't match my script it
>>> redirects me to None.
>>>
>>> Any thoughts?
>>>
>>> On Wednesday, February 26, 2014 2:08:11 PM UTC-5, Austin Taylor wrote:
>>>>
>>>> Hello,
>>>>
>>>> I setup a form similar to the display form on the tutorial:
>>>>
>>>> def display_form():
>>>> form = FORM('Your name:',
>>>> INPUT(_name='userinput',
>>>> requires=IS_IPV4()),INPUT(_type='submit'))
>>>> if form.process().accepted:
>>>> session.flash = 'form accepted'
>>>> redirect(URL('next'))
>>>> elif form.errors:
>>>> response.flash = 'form has errors'
>>>> else:
>>>> response.flash = 'please fill the form'
>>>> return dict(form=form)
>>>>
>>>> but for some reason it takes ANY user input and runs the redirect
>>>> function, even if there is no user input.
>>>>
>>>> How could I have the input validated and then perform a redirection if it
>>>> approved. I thought that is what the form.process().accepted was for.
>>>>
>>>>
>>>>
>>>>
--
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/groups/opt_out.