Re: [web2py] Re: Custom forms controller and view separation of concerns

2013-04-09 Thread Nguyen Minh Tuan
Anthony, thanks for your help!



On 9 April 2013 17:57, Anthony  wrote:

> All HTML helpers act like dictionaries with respect to their attributes
> (and attributes beginning with "_" become HTML element attributes), so for
> a string field:
>
> f.custom.widget.fieldname['_size']=10
>
> will yield:
>
>  "text" value="" />
>
> Anthony
>
>
> On Tuesday, April 9, 2013 5:42:49 AM UTC-4, Nguyen Minh Tuan wrote:
>>
>> Hi Anthony,
>>
>> I try to custom view by using form.custom,
>> But I have trouble in format control, Ex : I want to set textbox size to
>> 10 or whatever
>> Can I add more attributes to form.custom.widget.fieldname?
>>
>> Thanks,
>> Tuan.
>>
>> On Sunday, October 7, 2012 9:44:57 PM UTC+7, Anthony wrote:
>>
>>> Depending on what you want to do on the processing side and what you
>>> want to do on the display side, you probably don't have to completely
>>> repeat everything. You can use form.custom.widget.fieldname in the view if
>>> that is suitable. You can also use the server-side DOM to add classes, etc.
>>> Another option is to make the "formstyle" argument to SQLFORM.factory a
>>> callable, which can generate whatever form layout you want.
>>>
>>> Anthony
>>>
>>> On Saturday, October 6, 2012 7:31:12 PM UTC-4, Austin Cormier wrote:

 That definitely works and I've done it like that a couple times, but
 then I'm defining the input fields in two separate places.

 I'm thinking that maybe I have a custom view function that can take a
 vanilla form and then add my styling to it automatically.  If I only had to
 do a few forms it wouldn't be a big deal but I want to try and keep the
 duplication as minimal as possible.

 On Saturday, October 6, 2012 6:18:49 PM UTC-4, Anthony wrote:
>
> Just use 
> SQLFORM.factoryin
>  the controller to define the form fields, and then build the form
> manually in the view (possibly using some of the 
> form.customitems).
>
> Anthony
>
> On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:
>>
>> So I have the following customer form defined in my view for
>> prototyping:
>>
>> form = FORM(FIELDSET(DIV(LABEL('Email Address',
>> _class="control-label"),
>>  DIV(INPUT(_class="input-**large",
>> _id="email",
>>_name='email',
>> requires=IS_NOT_EMPTY()),
>>  _class="controls"),
>>  _class="control-group"),
>>  DIV(DIV(BUTTON("Add Email", _type='submit',
>> _class="btn"),
>>  _class="controls"),
>>  _class="control-group"),
>>
>>
>>  _class="gebo"),
>>_class="form-horizontal")
>>
>> The issue is that I need to define the form in the controller so that
>> I can run through the form accept (don't want to do that in the views).
>>  Even though I'm doing this in the controller, I would like the view to 
>> be
>> responsible for styling the form.  Are there any useful techniques anyone
>> knows of so that I can do this in a reusable and maintainable way across 
>> my
>> application?
>>
>  --
>
> ---
> 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/Ecy_tG1o-3k/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Custom forms controller and view separation of concerns

2013-04-09 Thread Anthony
All HTML helpers act like dictionaries with respect to their attributes 
(and attributes beginning with "_" become HTML element attributes), so for 
a string field:

f.custom.widget.fieldname['_size']=10

will yield:



Anthony


On Tuesday, April 9, 2013 5:42:49 AM UTC-4, Nguyen Minh Tuan wrote:
>
> Hi Anthony,
>  
> I try to custom view by using form.custom,
> But I have trouble in format control, Ex : I want to set textbox size to 
> 10 or whatever
> Can I add more attributes to form.custom.widget.fieldname?
>  
> Thanks,
> Tuan. 
>
> On Sunday, October 7, 2012 9:44:57 PM UTC+7, Anthony wrote:
>
>> Depending on what you want to do on the processing side and what you want 
>> to do on the display side, you probably don't have to completely repeat 
>> everything. You can use form.custom.widget.fieldname in the view if that is 
>> suitable. You can also use the server-side DOM to add classes, etc. Another 
>> option is to make the "formstyle" argument to SQLFORM.factory a callable, 
>> which can generate whatever form layout you want.
>>
>> Anthony
>>
>> On Saturday, October 6, 2012 7:31:12 PM UTC-4, Austin Cormier wrote:
>>>
>>> That definitely works and I've done it like that a couple times, but 
>>> then I'm defining the input fields in two separate places.
>>>
>>> I'm thinking that maybe I have a custom view function that can take a 
>>> vanilla form and then add my styling to it automatically.  If I only had to 
>>> do a few forms it wouldn't be a big deal but I want to try and keep the 
>>> duplication as minimal as possible.
>>>
>>> On Saturday, October 6, 2012 6:18:49 PM UTC-4, Anthony wrote:

 Just use 
 SQLFORM.factoryin
  the controller to define the form fields, and then build the form 
 manually in the view (possibly using some of the 
 form.customitems).

 Anthony

 On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:
>
> So I have the following customer form defined in my view for 
> prototyping:
>
> form = FORM(FIELDSET(DIV(LABEL('Email Address', 
> _class="control-label"), 
>  DIV(INPUT(_class="input-large", _id="email", 
>_name='email', 
> requires=IS_NOT_EMPTY()), 
>  _class="controls"), 
>  _class="control-group"),
>  DIV(DIV(BUTTON("Add Email", _type='submit', 
> _class="btn"), 
>  _class="controls"), 
>  _class="control-group"), 
>   
>   
>  
>  _class="gebo"),
>_class="form-horizontal")
>
> The issue is that I need to define the form in the controller so that 
> I can run through the form accept (don't want to do that in the views). 
>  Even though I'm doing this in the controller, I would like the view to 
> be 
> responsible for styling the form.  Are there any useful techniques anyone 
> knows of so that I can do this in a reusable and maintainable way across 
> my 
> application?
>


-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Custom forms controller and view separation of concerns

2013-04-09 Thread Nguyen Minh Tuan
Hi Anthony,
 
I try to custom view by using form.custom,
But I have trouble in format control, Ex : I want to set textbox size to 10 
or whatever
Can I add more attributes to form.custom.widget.fieldname?
 
Thanks,
Tuan. 

On Sunday, October 7, 2012 9:44:57 PM UTC+7, Anthony wrote:

> Depending on what you want to do on the processing side and what you want 
> to do on the display side, you probably don't have to completely repeat 
> everything. You can use form.custom.widget.fieldname in the view if that is 
> suitable. You can also use the server-side DOM to add classes, etc. Another 
> option is to make the "formstyle" argument to SQLFORM.factory a callable, 
> which can generate whatever form layout you want.
>
> Anthony
>
> On Saturday, October 6, 2012 7:31:12 PM UTC-4, Austin Cormier wrote:
>>
>> That definitely works and I've done it like that a couple times, but then 
>> I'm defining the input fields in two separate places.
>>
>> I'm thinking that maybe I have a custom view function that can take a 
>> vanilla form and then add my styling to it automatically.  If I only had to 
>> do a few forms it wouldn't be a big deal but I want to try and keep the 
>> duplication as minimal as possible.
>>
>> On Saturday, October 6, 2012 6:18:49 PM UTC-4, Anthony wrote:
>>>
>>> Just use 
>>> SQLFORM.factoryin
>>>  the controller to define the form fields, and then build the form 
>>> manually in the view (possibly using some of the 
>>> form.customitems).
>>>
>>> Anthony
>>>
>>> On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:

 So I have the following customer form defined in my view for 
 prototyping:

 form = FORM(FIELDSET(DIV(LABEL('Email Address', 
 _class="control-label"), 
  DIV(INPUT(_class="input-large", _id="email", 
_name='email', 
 requires=IS_NOT_EMPTY()), 
  _class="controls"), 
  _class="control-group"),
  DIV(DIV(BUTTON("Add Email", _type='submit', 
 _class="btn"), 
  _class="controls"), 
  _class="control-group"),   

  

  _class="gebo"),
_class="form-horizontal")

 The issue is that I need to define the form in the controller so that I 
 can run through the form accept (don't want to do that in the views).  
 Even 
 though I'm doing this in the controller, I would like the view to be 
 responsible for styling the form.  Are there any useful techniques anyone 
 knows of so that I can do this in a reusable and maintainable way across 
 my 
 application?

>>>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Custom forms controller and view separation of concerns

2012-10-07 Thread Anthony
Depending on what you want to do on the processing side and what you want 
to do on the display side, you probably don't have to completely repeat 
everything. You can use form.custom.widget.fieldname in the view if that is 
suitable. You can also use the server-side DOM to add classes, etc. Another 
option is to make the "formstyle" argument to SQLFORM.factory a callable, 
which can generate whatever form layout you want.

Anthony

On Saturday, October 6, 2012 7:31:12 PM UTC-4, Austin Cormier wrote:
>
> That definitely works and I've done it like that a couple times, but then 
> I'm defining the input fields in two separate places.
>
> I'm thinking that maybe I have a custom view function that can take a 
> vanilla form and then add my styling to it automatically.  If I only had to 
> do a few forms it wouldn't be a big deal but I want to try and keep the 
> duplication as minimal as possible.
>
> On Saturday, October 6, 2012 6:18:49 PM UTC-4, Anthony wrote:
>>
>> Just use 
>> SQLFORM.factoryin
>>  the controller to define the form fields, and then build the form 
>> manually in the view (possibly using some of the 
>> form.customitems).
>>
>> Anthony
>>
>> On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:
>>>
>>> So I have the following customer form defined in my view for prototyping:
>>>
>>> form = FORM(FIELDSET(DIV(LABEL('Email Address', 
>>> _class="control-label"), 
>>>  DIV(INPUT(_class="input-large", _id="email", 
>>>_name='email', 
>>> requires=IS_NOT_EMPTY()), 
>>>  _class="controls"), 
>>>  _class="control-group"),
>>>  DIV(DIV(BUTTON("Add Email", _type='submit', 
>>> _class="btn"), 
>>>  _class="controls"), 
>>>  _class="control-group"),   
>>> 
>>>
>>>  _class="gebo"),
>>>_class="form-horizontal")
>>>
>>> The issue is that I need to define the form in the controller so that I 
>>> can run through the form accept (don't want to do that in the views).  Even 
>>> though I'm doing this in the controller, I would like the view to be 
>>> responsible for styling the form.  Are there any useful techniques anyone 
>>> knows of so that I can do this in a reusable and maintainable way across my 
>>> application?
>>>
>>

-- 





[web2py] Re: Custom forms controller and view separation of concerns

2012-10-06 Thread Austin Cormier
That definitely works and I've done it like that a couple times, but then 
I'm defining the input fields in two separate places.

I'm thinking that maybe I have a custom view function that can take a 
vanilla form and then add my styling to it automatically.  If I only had to 
do a few forms it wouldn't be a big deal but I want to try and keep the 
duplication as minimal as possible.

On Saturday, October 6, 2012 6:18:49 PM UTC-4, Anthony wrote:
>
> Just use 
> SQLFORM.factoryin
>  the controller to define the form fields, and then build the form 
> manually in the view (possibly using some of the 
> form.customitems).
>
> Anthony
>
> On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:
>>
>> So I have the following customer form defined in my view for prototyping:
>>
>> form = FORM(FIELDSET(DIV(LABEL('Email Address', 
>> _class="control-label"), 
>>  DIV(INPUT(_class="input-large", _id="email", 
>>_name='email', 
>> requires=IS_NOT_EMPTY()), 
>>  _class="controls"), 
>>  _class="control-group"),
>>  DIV(DIV(BUTTON("Add Email", _type='submit', 
>> _class="btn"), 
>>  _class="controls"), 
>>  _class="control-group"), 
>> 
>>  
>>  _class="gebo"),
>>_class="form-horizontal")
>>
>> The issue is that I need to define the form in the controller so that I 
>> can run through the form accept (don't want to do that in the views).  Even 
>> though I'm doing this in the controller, I would like the view to be 
>> responsible for styling the form.  Are there any useful techniques anyone 
>> knows of so that I can do this in a reusable and maintainable way across my 
>> application?
>>
>

-- 





[web2py] Re: Custom forms controller and view separation of concerns

2012-10-06 Thread Anthony
Just use 
SQLFORM.factoryin
 the controller to define the form fields, and then build the form 
manually in the view (possibly using some of the 
form.customitems).

Anthony

On Saturday, October 6, 2012 2:07:49 PM UTC-4, Austin Cormier wrote:
>
> So I have the following customer form defined in my view for prototyping:
>
> form = FORM(FIELDSET(DIV(LABEL('Email Address', 
> _class="control-label"), 
>  DIV(INPUT(_class="input-large", _id="email", 
>_name='email', 
> requires=IS_NOT_EMPTY()), 
>  _class="controls"), 
>  _class="control-group"),
>  DIV(DIV(BUTTON("Add Email", _type='submit', 
> _class="btn"), 
>  _class="controls"), 
>  _class="control-group"), 
> 
>  
>  _class="gebo"),
>_class="form-horizontal")
>
> The issue is that I need to define the form in the controller so that I 
> can run through the form accept (don't want to do that in the views).  Even 
> though I'm doing this in the controller, I would like the view to be 
> responsible for styling the form.  Are there any useful techniques anyone 
> knows of so that I can do this in a reusable and maintainable way across my 
> application?
>

--