I think that makes sense, putting the logic in the controllers.

Thanks for the feedback.

On Nov 22, 7:38 pm, Cliff <[email protected]> wrote:
> You can simplify the view further if you always return something named
> "form."
>
> I'm biased in favor putting as much logic as possible in the models &
> controllers.
>
> On Nov 22, 5:09 pm, Adrian Edwards <[email protected]> wrote:
>
> > Thanks Cliff. I like your suggestion better. Now I can simply have the
> > view check
>
> > if type(form) is SQLFORM):
> > ....display form
> > else:
> > ...display message
>
> > On Nov 22, 5:05 pm, Cliff <[email protected]> wrote:
>
> > > One way to do it.  There are others I'm certain...
>
> > > Controller
>
> > > if time_in_range:
> > >     form = SQLFORM(....
> > > if something_else:
> > >     form = 'something else' # or any expression you like
> > > if another_thing:
> > >     form = 'another thing'
>
> > > return dict(form=form....)
>
> > > If you want to use different views, check out response.view in ch 4 of
> > > the Official Web2py Book.
>
> > > On Nov 22, 4:12 pm, Adrian Edwards <[email protected]> wrote:
>
> > > > Hello again,
>
> > > > This time I have a form design question.
> > > > I have a view who's content is date dependent where if date.today() is
> > > > in-between start_date and end_date then a SQLFORM is displayed.
> > > > Otherwise display a custom message, i.e. "Time has expired".
>
> > > > In my first solution I added the logic in the controller that checks
> > > > the date range, and then in the view did a check where if form is
> > > > NoneType display the "Time has expired" message, otherwise display the
> > > > SQLFORM fields.
>
> > > > While this works, its not very expandable. If I now want multiple
> > > > types of messages, or behavior it will make the view unwieldy.
>
> > > > How do you think is the best way to handle this?
>
> > > > Adrian
>
>

Reply via email to