You need to sign in to do that
Don't have an account?
Itay Shechter 10
Unknown constructor error in visualforce page
Hi, I'm trying to use a standardcontroller in the Visualforce page in order to use it in a custom button. But I'm having this error:
So, this is the code:
Thanks!
Unknown constructor 'CarController.CarController(ApexPages.StandardController controller)'I believe that I need to add something to the controller, but I could not find a solution that worked for me(I tried all the solutions that I found online)...
So, this is the code:
<apex:page standardController="Case" extensions="CarController" lightningStylesheets="true" title="test"> <apex:form> <apex:pageMessages/> <apex:pageBlock > <apex:pageBlockSection columns="2"> <apex:inputField value="{!abc.Name__c}"/> <apex:inputField value="{!abc.License_Number__c}"/> <apex:inputField value="{!abc.Manufacturer__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}" styleClass="slds-button slds-button_brand"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
public class CarController{ public Car__c abc {Get;Set;} public CarController() { abc = new Car__c(); } public PageReference save(){ try{ INSERT abc; } catch (exception e){ } return null; } }P.S. I'm not a developer, just try to learn in order to get there one day... so I'll be happy to understand what is missing.
Thanks!
Please use the below updated class:
You have to change the constructor like below.
Thanks,
Maharajan.C
All Answers
Please use the below updated class:
You have to change the constructor like below.
Thanks,
Maharajan.C