I suppose that's fine -- it just wasn't clear to where you were redirecting
or why.
On Wednesday, October 7, 2015 at 11:11:27 PM UTC-4, Yebach wrote:
>
> thanx for this
>
> Yes I have a redirect to another page.
>
> So if user creates a shift that already exists (code is based on times of
> duration), i want to give him a choice to go to that shift and activate it
> in case its status is archived
>
> do you recommend another way. I give now flash message but if i could do
> smth else it is also ok
>
> thank you again
>
> 2015-10-07 20:12 GMT+08:00 Anthony
>
>> so far the link and everything works ok, but the first validators are not
>>> working so i get an error cos the sh_.field which is autogenerate is not
>>> done
>>>
>>> if (grid_shifts.create_form and grid_shifts.create_form.errors) or (
>>> grid_shifts.update_form and grid_shifts.update_form.errors):
>>>
>>
>> Are you saying that even when some fields are left empty, the above
>> condition is nevertheless false (i.e., no form errors) and the following
>> code therefore does not run?
>>
>> Also, how about something like:
>>
>> form = grid_shifts.create_form or grid_shifts.update_form
>> if form and form.errors:
>>
>>
>> codeField = grid_shifts.element('input[name=sh_code]')['value']
>>>
>>
>> Instead, how about:
>>
>> codeField = form.vars.sh_code
>>
>>
>>
>>> shiftId = db(db.shifts.sh_code == codeField).select(db.shifts.id).
>>> as_list()
>>> redId = shiftId[0]["id"]
>>>
>>
>> No need for .as_list() or the dictionary syntax -- just do:
>>
>> redId = db(db.shifts.sh_code == codeField).select().first().id
>>
>>
>>
>>> session.flash= A(T("Click here if you want to activate shift with that
>>> code or if you want to be redirected to the shift."), _href=URL(
>>> 'turnusi/edit/shifts', args= redId))
>>>
>>
>> Why are you using session.flash -- is there a redirect after this?
>>
>> Anthony
>>
>>>
>>> --
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/2ikYrc84qB4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Lep pozdrav
>
> Vid Ogris
>
>
>
--
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/d/optout.