-2

How to convert visualforce in lightning in salesforce

<apex:page controller="MyContactDetailController">
    <apex:form >

  <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:outputField value="{!con1.FirstName}"/>
            <apex:outputField value="{!con1.LastName}"/>
            <apex:outputField value="{!con1.Email}"/>
            <apex:outputField value="{!con1.Phone}"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Edit" action="{!Edit}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
Keith C
  • 135,775
  • 26
  • 201
  • 437
Anish Kumar
  • 1
  • 1
  • 7

2 Answers2

1

If it is purely output, there is now a lightning:outputField component available. Sample code from the help:

<aura:component>
    <!-- Replace the record ID with your own -->
    <lightning:recordViewForm recordId="001XXXXXXXXXXXXXXX" objectApiName="Contact">
        <div class="slds-box slds-theme_default">
            <lightning:outputField fieldName="Name" />
            <lightning:outputField fieldName="Phone"/>
            <lightning:outputField fieldName="Email" />
            <lightning:outputField fieldName="Birthdate" />
            <lightning:outputField fieldName="LeadSource" />
        </div>
    </lightning:recordViewForm>
</aura:component>
Keith C
  • 135,775
  • 26
  • 201
  • 437
  • <apex:page controller="MyContactDetailController"> <apex:form >

    <apex:pageBlock > <apex:pageBlockSection > <apex:outputField value="{!con1.FirstName}"/> <apex:outputField value="{!con1.LastName}"/> <apex:outputField value="{!con1.Email}"/> <apex:outputField value="{!con1.Phone}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Edit" action="{!Edit}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> Convert in lightning

    – Anish Kumar Dec 11 '17 at 10:02
  • @AnishKumar You hadn't selected the Visualforce text and used the {} button in your question. I've done that now so the markup appears. – Keith C Dec 11 '17 at 10:57
  • I have to convert this page into lightning.How can I implement this – Anish Kumar Dec 11 '17 at 11:37
  • 1
    @AnishKumar To do that work you will need to learn about Lightning Components. A place to start is https://trailhead.salesforce.com/en/modules/lex_dev_lc_basics. – Keith C Dec 11 '17 at 11:57
0

See here the detailed info already discussed on the same issue: Lightning - How to use force:inputField?

Salesfore developer guide: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_force_outputField.htm

Khushboo Dua
  • 441
  • 2
  • 12