You need to sign in to do that
Don't have an account?
Kunal Purohit 4
How to create a Visualforce page with One field?
Hello Folks,
I am learning VisualForce page. I want to create a VF page with one field and this page should make the api call/fetch the data from custom object and show it in that field. I have tried with below code but it is generating an error:
Unknown property 'ZipCodeController.ProspectUser__c'
Here ProspectUser__c is an object name and ZipCode__c is a field name.
VF Page: <apex:page controller ="ZipCodeController" > <apex:form> <apex:inputField value = "{!ProspectUser__c.ZipCode__c}"/> </apex:form> </apex:page> Controller: public with sharing class ZipCodeController { public List<ProspectUser__c> getProspectUser{get;set;} public ZipCodeController() { getProspectUser = [Select ZipCode__c FROM ProspectUser__c LIMIT 1]; } }
Please suggest.
The Vf page and Apex class can be as below.
Vf Page:
Apex:
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
<apex:form >
<apex:inputField value="{!ObjectName.FieldName}" />
</apex:form>
</apex:page>
Replace "ObjectName" and "FieldName" with the actual object and field names that you want to display on the page.
Click "Save".
You can also add other components to the page like input text, output text and action support or command button to submit the form data.
When you navigate to the page, you will see the input field for the specified field of the specified object. You can also customize the look and feel of the page by using Salesforce's Visualforce markup language and CSS.