Hi,

I am in the process of creating a site what will allow the user to
generate a form with whatever questions they would like to ask their
users. I allow the user to create a form, add questions and choose
various options for each one of the questions. I then save these
options as a serialized hash in the database so that I can generate
their form from the options they have chosen.

In my new form view i then loop over this hash creating form fields
for each field I have stored in the hash. I am currently using the
eval method for each field so that I can create a string of the field
options, and then have ruby evaluate that into usable code. Here is an
example:

(I am using HAML and the simple_form gem)
= eval("#{field['form_name']}.input :#{field['field_name']}, :label =>
'#{field['wording'][I18n.locale.to_s]}', :hint => '#{field['hint']
[I18n.locale.to_s]}', :required => (#{field['required']} == 1)" ) if
field['display'] == 1

I am running into with using eval and Haml is when I am creating a
fields_for section and using eval to do so:
eval("#{field['form_name']}.simple_fields_for :#{field['association_name']}
do |#{field['association_name']}|")'

I think that Haml does not recognize this as ruby syntax and therefor
does not automatically close off any of the tags (from what I can
gather).

Any help is appreciated!

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" 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/haml?hl=en.

Reply via email to