On Oct 11, 2009, at 2:04 PM, mr.freeze wrote:

>
> The example I gave was for auth membership.  Say you wanted to style
> the form based on which group they were a member of.  You would need a
> style sheet for each group.  Also, what would happen when a new group
> was created?

You could generate the CSS file dynamically (new feature!), though  
it'd probably be overkill here.

Alternatively you could generate the class definition in <head>, which  
would override the CSS file's default. That would be a little cleaner  
that a local style=, I think.

>
> On Oct 11, 3:24 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>> Then dynamically include different stylesheets?
>>
>> <style type="text/css">
>> {{if auth.is_logged_in():}}
>> @import "auth_form.css"
>> {{else:}}
>> @import "reg_form.css"
>> {{pass}}
>> </style>
>> -Thadeus
>>
>> On Sun, Oct 11, 2009 at 2:58 PM, mr.freeze <nat...@freezable.com>  
>> wrote:
>>
>>> I think CSS is definitely the best way if you don't need this  
>>> level of
>>> dynamism and know all of the necessary selectors ahead of time.  But
>>> if you wanted to style a form based on a runtime variable (auth
>>> membership for example), or manipulate the form in any other way for
>>> that matter, I think this is useful.
>>
>>> On Oct 11, 2:39 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>>>> What is wrong with using a .css file?
>>
>>>> -Thadeus
>>
>>>> On Sun, Oct 11, 2009 at 2:04 PM, mdipierro  
>>>> <mdipie...@cs.depaul.edu>
>>> wrote:
>>
>>>>> It is there already
>>
>>>>> form.element(_type='submit')['_style']="color:white; background-
>>>>> color:blue; font-weight:bold"
>>
>>>>> It only finds the first matching element.
>>
>>>>> On Oct 11, 1:16 pm, "mr.freeze" <nat...@freezable.com> wrote:
>>>>>>> Good point - and addresses the original post (as it could have  
>>>>>>> been
>>> more
>>>>>>> simply done this way);
>>
>>>>>> Not technically since this would affect everything inside the  
>>>>>> form
>>> and
>>>>>> not just the submit button.  What about a member function 'find'
>>> added
>>>>>> to XmlComponent or DIV (which I think most helpers inherit  
>>>>>> from) that
>>>>>> allows you to traverse the inner components and return the  
>>>>>> matching
>>>>>> components for given criteria.  The pseudo-code might look like  
>>>>>> this:
>>
>>>>>> submit = form.components.find(XML.attribute("type")=="submit")[0]
>>>>>> submit['_style'] = "color:white; background-color:blue; font-
>>>>>> weight:bold"
>>
>>>>>> On Oct 11, 12:29 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
>>
>>>>>>> On Sun, Oct 11, 2009 at 11:04 AM, mdipierro <
>>> mdipie...@cs.depaul.edu>
>>>>> wrote:
>>
>>>>>>>> I do not think you cannot use decorators this way.
>>
>>>>>>> double negatives.... not sure what you intended to say (but  
>>>>>>> logical
>>>>> analysis
>>>>>>> says "... think you can use decorators this way...");
>>
>>>>>>>> But I remind you crud.create is a function that returns   
>>>>>>>> SQLFORM
>>>>> which
>>>>>>>> is a FORM which is a heper as any other helper. Therefore you  
>>>>>>>> can
>>> do:
>>
>>>>>>>> form = crud.create(...)
>>>>>>>> form['_style']="color:white; background-color:blue;
>>> font-weight:bold"
>>
>>>>>>> Good point - and addresses the original post (as it could have  
>>>>>>> been
>>>>> more
>>>>>>> simply done this way);
>>
>>>>>>> Regardless, then
>>
>>>>>>> @style( color='white', background-color='blue', font- 
>>>>>>> weight='bold')
>>>>>>> form = crud.create(...)
>>
>>>>>>> would still be a readable thing (and just trivial to implement);
>>
>>>>>>> Alternatively, form.style( ...same kinds of parameters....)    
>>>>>>> could
>>> be
>>>>> used;
>>
>>>>>>> Anyway, this is about readability, and ease of infding this  
>>>>>>> stuff
>>> (as
>>>>> this
>>>>>>> post shows);
>>
>>>>>>> If there were a member function to FORM to set style, people who
>>> not
>>>>> have to
>>>>>>> stumble upon it.
>>
>>>>>>> Thoughts?
>>
>>>>>>>> On Oct 11, 10:47 am, Web2py-SuperFan <mwkan...@gmail.com>  
>>>>>>>> wrote:
>>>>>>>>> I really like that suggestion, would be much cleaner code and
>>>>> easier
>>>>>>>>> to configure different styles that have meaning by variable
>>> name
>>
>>>>>>>>> On Oct 10, 9:47 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
>>
>>>>>>>>>> I wonder if we could encapsulate, simplify this with a
>>> decorator,
>>>>>>>> something
>>>>>>>>>> like:
>>
>>>>>>>>>> @button( color='white', background='blue', font='bold' )
>>>>>>>>>> form = crud.create(...)
>>
>>>>>>>>>> Something like this could be useful for something like
>>
>>>>>>>>>> @button( my_admin_style )
>>>>>>>>>> form = crud.create(....)
>>
>>>>>>>>>> @button( my_warning_style )
>>>>>>>>>> form = ...
>>
>>>>>>>>>> .... just thinking out loud....
>>
>>>>>>>>>> On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan <
>>>>> mwkan...@gmail.com
>>>>>>>>> wrote:
>>
>>>>>>>>>>> took me a while to dig up the answer/solution, maybe can
>>> save
>>>>> someone
>>>>>>>>>>> else some time
>>
>>>>>>>>>>>    form = crud.create(...)
>>>>>>>>>>>    form=DIV(
>>>>>>>>>>>      form,
>>>>>>>>>>>      SCRIPT('''$(document).ready(function() {
>>>>>>>>>>>      $("input[type=submit]").val("Share");
>>>>>>>>>>>      });'''),
>>>>>>>>>>>      SCRIPT('''$(document).ready(function() {
>>>>>>>>>>>      $("input[type=submit]").css({
>>>>>>>>>>>      color:'white',
>>>>>>>>>>>      background:'blue',
>>>>>>>>>>>      font: 'bold'});
>>>>>>>>>>>      });'''),
>>>>>>>>>>>       )
>>
>>>>>>>>>>>     return dict(form=form)- Hide quoted text -
>>
>>>>>>>>>> - Show quoted text -
> >



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to