pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

[enhancement] Ability to add custom attributes to input fields #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i was thinking that it would be really handy to have a method that would
allow for setting custom attributes for input elements.

sometimes there is need to for example specify custom styling for one field
and there is no easy enough method to do that.

Original issue reported on code.google.com by ergo14@gmail.com on 9 Feb 2009 at 9:16

GoogleCodeExporter commented 9 years ago
Please give an example of what you are thinking.

Original comment by jbel...@gmail.com on 9 Feb 2009 at 1:47

GoogleCodeExporter commented 9 years ago
lets say we have a model that we want to have a textarea field, it accepts rows 
and
cols as parameter, which kinda does the trick , but in modern approach it would 
be
more approperiate to add style="height:255px" for example - this is quite 
crucial for
situations when we want to attach some kind of RTE to the field

other situation where i think that one may need the ability to specify custom 
tags
are RIA applications, its very common to pass some params as encoded class 
names like
class="id-55 active drag-and-drop-enabled" etc. then selector engines are 
reading the
values and parse them into meaningful data for widgets etc.

Original comment by ergo14@gmail.com on 9 Feb 2009 at 5:29

GoogleCodeExporter commented 9 years ago
The purist in me says that these should be done with css, but I recognize that 
in
practice it can be useful to have quick & dirty options available, so I would 
accept
a patch for this.  There is the beginnings of a hook for this already in 
fields.py
(look for html_attributes) but about 90% of the work remains. :)

Original comment by jbel...@gmail.com on 11 Feb 2009 at 2:48

GoogleCodeExporter commented 9 years ago
yup, im a purist too, and i use css, BUT there are onclicks and other useful 
attribs
as well ;-)

Original comment by ergo14@gmail.com on 11 Feb 2009 at 5:33

GoogleCodeExporter commented 9 years ago
This adds almost nothing, except some documentation and the support for 
.options()
which sends specified options to final renderers. The webhelpers fork used in 
here
will render them as separate HTML attributes when they don't match renderers 
options.

This patch also highlights the availability of the same functionalities on the
render() functions. This should work also with home-brew renderers, based on 
the new
WebHelpers 0.6 for example, if someone wanted to have some customer renderers.

Comments are welcome

Original comment by wackysa...@gmail.com on 22 Mar 2009 at 3:49

Attachments:

GoogleCodeExporter commented 9 years ago
Applied with changes:
 - renamed .options to .with_html
 - removed **html_options from render methods

Thanks!

Original comment by jbel...@gmail.com on 23 Mar 2009 at 6:32