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
Nitin Palmure 5Nitin Palmure 5 

Populate SOQL result in form fields instead of table.

I am trying to create a VF page where user can search for a record based on id field and edit it on the same page.
I have searched and found almost all the solutions which displays values in Tablular form.
I want to display the results in a Form fields itself and enable users to make changes and save.

Can anyone suggest on this ?

Thank you.
Raj VakatiRaj Vakati
Refer this link for sample code 

https://www.forcetalks.com/blog/how-to-use-fieldset-in-salesforce-visualforce-pages/
https://www.greytrix.com/blogs/salesforce/2016/12/29/addingcreating-fieldset-in-salesforce/
https://www.forcescript.com/using-fieldset-with-visualforce-and-apex/

Code
 
public class AccountFieldSetController {
    public String queryString{get;set;}
    public List<Account> accountList{get;set;}
    public AccountFieldSetController(){
        queryString = 'select id';
        for(Schema.FieldSetMember fld :SObjectType.Account.FieldSets.accountFieldSet.getFields()) {
         queryString += ', ' + fld.getFieldPath();
        }
        queryString += ' from Account limit 5';
          
        accountList= Database.query(queryString);
    }
      
}
 
<apex:page controller="AccountFieldSetController" tabStyle="Account">
  <apex:form >
      <apex:pageblock >        
          <apex:pageBlockSection title="Account list" collapsible="false">
             <apex:pageBlockTable value="{!accountList}" var="acc">
                 <apex:repeat value="{!$ObjectType.Account.fieldsets.accountFieldSet}" var="fieldValue">
                     <apex:column value="{!acc[fieldValue]}">
                     </apex:column>
                 </apex:repeat>
             </apex:pageBlockTable>
          </apex:pageBlockSection>
            
          <apex:pageBlockSection title="Account Dynamic query" collapsible="false">
              <apex:outputText value="Query is: {!queryString}" />
          </apex:pageBlockSection>
            
      </apex:pageblock>
    </apex:form>
</apex:page>

 
Nitin Palmure 5Nitin Palmure 5
Hi Raj, 

Thank you for the help.
However, is it possible to have this output without using any kind of table. 
As I am trying to implement it in force.com site and want to avoid the borders and background that comes with it.
It is very difficult to get rid of them.

Thank you