function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DaneshDanesh 

Library to convert SF Fields into HTML input fields

Does anyone know of a library that converts SF fields into HTML elements? I want to build an HTML form for Contacts but I'd like to do it more dynamically. I'm iterating over all of the fields returned from the GET request so I'd like to generate the form on the fly, not hard-code it.

For example, the name fields are text field, so I'd like it to generate an input tag with type=text. If my Contact has a picklist, I'd like the form to render a select tag.

Ideally, I'd like a gem for Ruby on Rails but any library will help for now.
RamuRamu (Salesforce Developers) 
see if this helps

https://mindfiresfdcprofessionals.wordpress.com/tag/visual-force-equivalent-html-code/
DaneshDanesh
No sorry, it does not.

I'm not looking for converting VF to HTML. I've parsed the result of calling the request, "..../sobjects/Contact/describe", so I know the type of each field. I'd like something that maps that to an HTML field.

For example, here's a textarea's result
{
    ...,
    "inlineHelpText"=>"One amazing text area",
    "label"=>"TestCustomTextArea",
    "length"=>255,
    "name"=>"TestCustomTextArea__c",
    "type"=>"textarea",
    ...
}


Ideally, the library would take that in and spit out an HTML text area with length 255, name specified, etc etc.

My current solution is to use this form builder (http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html) and just handle the "type" with a case/switch statement, then spit out the right one. That's just a bit manual :/