2

I'm relatively new to Salesforce and have ran into a problem. I want to display a simple form, but the fields won't show. I created a the same form again, but in a different way that would take more time to input lists and so on. Does anyone know why the bottom set of fields aren't showing? I've made sure they are all visible. Heres the code.

<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="1">
            <apex:inputText value="{!subject}" label="Brief Description" />
            <apex:inputText value="{!tsk.Description}" label="Long Description" />
            <apex:selectList value="{!location}" label="Location">
                <apex:selectOptions value="{!locations}">
                </apex:selectOptions>
            </apex:selectList>
            <apex:inputText value="{!subLocation}" label="Sub Location" />
            <apex:inputText value="{!category}" label="Category" />
            <hr/>
            <apex:inputField value="{!con.Gender__c}" label="Contracts" />
            <apex:inputField value="{!tsk.Description}" label="Long Description" />
            <apex:inputField value="{!tsk.Location__c}" label="Location" />
            <apex:inputField value="{!tsk.Sub_Location__c}" label="Sub Location" />
            <apex:inputField value="{!tsk.Category__c}" label="Category" /> 
            <apex:commandButton action="{!saveEntry}" value="Save" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

and the Controller:

public class maintenanceEntryController
{
public Task t {get; set;}
public Opportunity opp {get; set;}
public Contact con {get; set;}

public Task_c tak {get; set;}

public Task tsk {get; set;}
public String subject {get; set;}
public String description {get; set;}
public String location {get; set;}
public String subLocation {get; set;}
public String category {get; set;}

public List<String> locations {get; set;}

public void maintenanceEntryController()
{
    tsk = new Task();
}

public PageReference saveEntry()
{
    t.Subject = subject;
    t.Description = description;
    t.Location__c = location;
    t.Sub_Location__c = subLocation;
    t.Category__c = category;

    if(t.Location__c == 'General Grounds')
        t.OwnerID = '005e0000000ocy0'; // Ben Green
    if(t.Location__c == 'Vehicles')
        t.OwnerID = '005e0000000ocy5'; // Fleet Manager
    if((t.Location__c == 'Challenge Course') || (t.Location__c == 'Waterfront'))
        t.OwnerID = '005e0000000ocy0'; // Andrew Allison
    if((t.Location__c == 'Other') || (t.Sub_Location__c != ''))
        t.OwnerID = '005e0000000ocxv'; // Mikel Kadegis

    insert t;

    PageReference p = new PageReference(ApexPages.currentPage().getUrl());
    p.setRedirect(true);
    return p; // ApexPages.maintenanceTicketSubmitted;
}
public class Task_c
{
    public String t {get; set;}
}
}
3
  • 2
    I wonder if it is something as simple as the use of the <hr> tag. I've never looked in our CSS to see how we style that tag. Maybe it doesn't play nice with pageBlock? Have you used an inspector to look at the rendered HTML to discover what is being sent to the browser? (And what isn't, of course.)
    – pchittum
    Nov 8, 2013 at 22:33
  • 3
    On a side note, the practice of hard coding user IDs is deeply troublesome. Especially since you could create a workflow rule to manage this assignment for you, thus letting it be changed from the setup menu instead of code. I realize this may not be the code you plan to put into production, but look into workflow. It is your friend.
    – pchittum
    Nov 8, 2013 at 22:36
  • 4
    You tagged this as sites. Have you made sure the site profile has access to the fields? Nov 9, 2013 at 5:38

1 Answer 1

2

I just verified your code and it works fine for me, with the following differences:

  • Changed your custom fields in Visualforce to Description
  • Did not create a site and try this

So the VF code I tested this with looks like this:

<apex:page controller="maintenanceEntryController">

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:inputText value="{!subject}" label="Brief Description" />
                <apex:inputText value="{!tsk.Description}" label="Long Description" />
                <apex:selectList value="{!location}" label="Location">
                    <apex:selectOptions value="{!locations}">
                    </apex:selectOptions>
                </apex:selectList>
                <apex:inputText value="{!subLocation}" label="Sub Location" />
                <apex:inputText value="{!category}" label="Category" />
                <hr/>
                <apex:inputField value="{!con.Name}" label="Contracts" />
                <apex:inputField value="{!tsk.Description}" label="Long Description" />
                <apex:inputField value="{!tsk.Description}" label="Location" />
                <apex:inputField value="{!tsk.Description}" label="Sub Location" />
                <apex:inputField value="{!tsk.Description}" label="Category" /> 
                <apex:commandButton action="{!saveEntry}" value="Save" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>

</apex:page>

As Daniel mentioned, I would recommend confirming that the user has the appropriate access to these fields in your Site, and I would also make sure that you don't have any other access issues that would prevent the currently logged in user from seeing these fields.

Also notice that you have inputText on the top and inputField on the bottom section. apex:inputField will respect security where apex:inputText will not. So all of your public Strings that are being displayed on top are not subject to profile or field-level security.

Lastly, I made assumptions about what the rest of your page looked like, but since you only posted the apex:form section I could be missing other things. But it appears that the hr tag isn't causing the problem (at least in Safari).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .