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?
On Oct 11, 3:24 pm, Thadeus Burgess <[email protected]> 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 <[email protected]> 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 <[email protected]> wrote: > > > What is wrong with using a .css file? > > > > -Thadeus > > > > On Sun, Oct 11, 2009 at 2:04 PM, mdipierro <[email protected]> > > 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" <[email protected]> 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 <[email protected]> wrote: > > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro < > > [email protected]> > > > > 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 <[email protected]> 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 <[email protected]> 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 < > > > > [email protected] > > > > > > > >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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

