JeffV
2010-Feb-04 20:05 UTC
Suggestions on how to support user-customizable views and forms?
I''ve searched the archives and googled and can''t find much on
this. I
need to allow an app admin to be able to define the layout of various
views (and eventually various forms). The admin should be able to
specify a row and column number for each field they want presented
I''m thinking a view could look something like this:
<% = @layout.title %>
<br />
<table>
<% @layout.rows.each do |row| -%>
<tr>
<% row.columns do |col| -%>
<td><strong><%= col.label
%></strong></td>
<td><%= col.model.send(col.method) %></td>
<% end -%>
</tr>
<% end -%>
</table>
The "col" object contains the field''s label, db model class
name, and
model method (could be a column attribute or any model instance
method).
The "row" object, so far, is just an array of col objects.
I don''t have the db design for this yet either.
Thanks for any and all suggestions.
Jeff
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
JeffV
2010-Feb-04 20:12 UTC
Suggestions on how to support user-customizable views and forms?
I''ve searched the archives and googled and can''t find much on
this. I
need to allow an app admin the ability to define the layout of various
views (and eventually various forms). The admin should be able to
specify each field they want displayed and its row and column
positions. Eventually, the admin can change the field''s text label,
define it as read-only or writeable by users possessing a certain
permission, etc... but I need help with the basic approach first,
which is rendering a user-defined view.
I''m thinking the view code could look something like this:
<% = @layout.title %>
<br />
<table>
<% @layout.rows.each do |row| -%>
<tr>
<% row.columns do |col| -%>
<td><strong><%= col.label
%></strong></td>
<td><%= col.model.send(col.method) %></td>
<% end -%>
</tr>
<% end -%>
</table>
The "col" object contains the field''s label, db model class
name, and
model method (could be a column attribute or any model instance
method).
The "row" object, so far, is just an array of col objects.
@layout would be constructed by the model based on definitions found
in the db.
I don''t have the db design for this yet either.
Thanks for any and all suggestions.
Jeff
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.