On Tue, Sep 27, 2011 at 12:32 PM, Anthony <abasta...@gmail.com> wrote:
> You can use SQLFORM.factory and still have complete control over the form
> layout/appearance --
> see http://web2py.com/book/default/chapter/07#Custom-forms.
> But if you want to access any of the SQLFORM widgets independently, they are
> of the form SQLFORM.widgets.[field type].widget --
> see http://web2py.com/book/default/chapter/07#Widgets.
> Anthony
>
Somehow I completely missed this! Many apologies. Still, using this
approach I am still unclear as to how I might "fill" those widgets
when I'm using the SQLFORM custom form method. Ideally, I would fill
the form from the controller before display. I've tried:
   - form.vars.var = "value"
   - form.custom.var.widget.value = "value"

Neither of which work. Is this possible?
Matt


> On Tuesday, September 27, 2011 11:52:43 AM UTC-4, Matt wrote:
>>
>> On Tue, Sep 27, 2011 at 11:49 AM, Anthony <abas...@gmail.com> wrote:
>> > In Field(), represent defaults to None -- you have to specify a
>> > represent
>> > function of your own.
>> > Anthony
>> >
>>
>> Ah, I see. Is there a way to leverage the representations defined in
>> SQLFORM.factory for this? SQLFORM.factory worked to a certain degree
>> for my needs, but it also did not give me much freedom to design the
>> view the way I wanted. Instead, I've ended up creating this "model"
>> with the fields that I want, and I'm placing them one by one in the
>> view. The actual "widgets" that were rendered by SQLFORM.factory were
>> just fine - so can I use those somehow?
>>
>> Matt
>>
>> > On Tuesday, September 27, 2011 11:46:58 AM UTC-4, Matt wrote:
>> >>
>> >> On Tue, Sep 27, 2011 at 11:41 AM, Anthony <aba...@gmail.com> wrote:
>> >> > Do you need the field's widget or it's represent (they're two
>> >> > different
>> >> > things)? Note, the represent attribute is a function/callable
>> >> > (usually a
>> >> > lambda) that takes a value (and optionally a record), so if you want
>> >> > to
>> >> > use
>> >> > it directly, you have to call it and pass a value to it.
>> >> > {{=A.B.represent(your_value, optional_record)}}
>> >> > Would be similar for the widget.
>> >> > Anthony
>> >> >
>> >>
>> >> From what I read in the source, I determined that was how to do it.
>> >> However, when I try to call represent that way I'm getting an error
>> >> that the 'NoneType' object is not callable.
>> >>
>> >> This is what I've got:
>> >>
>> >> model:
>> >> class Test:
>> >>     name = Field('name', 'string')
>> >>
>> >> view:
>> >>         {{=terminal.name.represent("test")}}
>> >>
>> >> Matt
>> >>
>> >> > On Tuesday, September 27, 2011 11:19:08 AM UTC-4, Matt wrote:
>> >> >>
>> >> >> Hello,
>> >> >>    Is there a way to specify a value for the representation of a
>> >> >> Field
>> >> >> object? I have a class (lets call it A) with a Field object member
>> >> >> variable (lets call it B), in my view I call {{=A.B.represent}} in
>> >> >> order to display the default widget for this field. I would like to
>> >> >> "fill" that widget with a value as well, is that possible?
>> >> >>
>> >> >> Matt
>> >> >
>> >
>

Reply via email to