You need to sign in to do that
Don't have an account?
How can I make a simple vf page that accept user input and insert into custom object?
I'm new to salesforce and would like to create a sample vf page which accept user input and once I clicked on save it will get inserted into my custom object and I want another button to show the record of the custom object on vf page, can you please help me for the code of vf and controller.
Its just for my learning purpose.
Its just for my learning purpose.
Please check the below sample code.
Visualforce page:
Controller:
screenshot:
Hope this helps you!
Best Regards,
Jyothsna
All Answers
There are to many sample code are available in Google but i will recomand you please check below trailhead module which will help you alot in learning VF page
1) https://developer.salesforce.com/trailhead/module/visualforce_fundamentals
Sample code for Let us know if this will help you. Above sample is for contact object just replace that with custom object.
Thanks
Amit Chaudhary
Please check the below sample code.
Visualforce page:
Controller:
screenshot:
Hope this helps you!
Best Regards,
Jyothsna
@Ashish, // U can call Save method from ur vf page, which will save the record.
public class MyExtensionClass {
public ApexPages.StandardController sc;
public Contact ct{get;set;}
public MyExtensionClass(ApexPages.StandardController sc) {
this.sc = sc;
Contact c = (Contact) sc.getRecord();
}
public PageReference save() {
return sc.save();
}
}
Hope it helps!!
Please check below post for for controller. I hope that will help you
1) https://developer.salesforce.com/trailhead/visualforce_fundamentals/visualforce_custom_controllers
Please try below code
Let us know if this will help you
Thank's
Amit Chaudhary
I have followed your steps but I am getting this error ("Error: Unsupported attribute vlaue in <apex:inputField> in CreateContact at line 8 column 71").
Thanks,
Ganesh Gayakwad