+ Start a Discussion
Josh Anderson 30Josh Anderson 30 

Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'

Trying to build a webpage for teams to be able to submit cases and attachments. For some reason I am getting a "Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'" error and even though I add the standard set controller I am still getting an error. Am I missing something on this for where I need to be adding this? 

<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" >
    <html lang="en">
            <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/>
            <!-- Bootstrap -->
            <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/>
            <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/>
            <title>Submit a Case</title>
                p, li, .description{
                font-weight: 400;
                line-height: 1.8rem;
                padding-top: 2rem;
                background: #2196f3;
                .background-black:hover, .background-black:focus{
                background: #2386d3 !important;
                section .section-inner h2{
                color: #fff;
                .round {
                border-radius: 100px;
                margin: 0;
                color: #9a9a9a
                .longBox{height: 100px;}
                @media screen and (max-width: 500px){
                .brand .h1-seo{
                font-size: 2.2rem;
            <div class="container">
                <apex:form >
                    <form class="form-signin"><br/><br/><br/>
                        <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/>
                        <h5 class="form-signin-heading">Email</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Email__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Subject</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Subject}" required="true"/>
                        <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.What_are_you_experiencing__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Location_of_issue__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Source Type</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Source_Type__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Description</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control longBox" value="{!case.Description}" required="true"/><br/>
                        <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="submit">Submit</button>
                        <apex:pageBlock >
                            <apex:pageBlockButtons location="top">
                                <apex:commandButton id="uploadAttachment" value="Upload" action="{!uploadAttachment}"/>
                            <apex:pageBlockSection columns="1">
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel >Attachment</apex:outputLabel>
                                    <apex:inputField value="{!cs.Name}"/>
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel >Attachment</apex:outputLabel> 
                                    <apex:inputFile value="{!document}" accept="doc, docx, txt, pdf, xlsx" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" /> 
            <!-- /container -->
            <!-- Bootstrap core JavaScript
================================================== -->
            <!-- Placed at the end of the document so the pages load faster -->

public class attachController {
    public List<Attachment> fileList {get; set;}
    public Case cs {get; set;}
    public Attachment attach {get; set;}
    public ApexPages.StandardSetController stdCntrlr {get; set;}
    public attachController(ApexPages.StandardSetController controller) {
        stdCntrlr = controller;
    public attachController() {
        cs = new Case();
        attach = new Attachment();
        fileList = new List<Attachment>();
    public Case getCS(){
        if(cs == null) 
            cs = new Case();
        return cs; 
    public List<Attachment> getAttachments(){
        if(fileList == null) 
            fileList = new List<Attachment>();
        return fileList; 
    public PageReference AddAttachs() {
        fileList.add(new Attachment());
        return null;
    public PageReference uploadAttachment() { 
        insert cs;
        if(cs != null) {            
            List<Attachment> attachments = new List<Attachment>();                               
            for(Attachment att : fileList)              
                if(att.name != null && att.body != null)
                    attachments.add(new Attachment(parentId = cs.Id, name = att.name, body = att.body)) ;                
            if(attachments != null){
                upsert attachments;                 
                ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.INFO, attachments.size() + ' file(s) uploaded successfully'));                                              
            }else {
                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Error uploading file'));
        return null;      

Bishal Singh 12Bishal Singh 12
Hi you need to define your controller as:
public attachController(ApexPages.StandardController std){

Josh Anderson 30Josh Anderson 30
Thanks for that Bishal. I am now getting an error:
Could not resolve field 'Name' from <apex:inputField> value binding '{!cs.Name}' in page ProductCaseExternal

If I remove the visualforce for the attachment my visualforce saves but the attachment is the whole reason I have the extension.