In your VF page, use both components, inputField and outputField with opposite rendering condition. What you have to pay attention to is to update the components everytime an action specified in actionSupport is called. You can do so by wrapping both inputField and outputField components in an outputPanel and specifying the outputPanel's ID as the element to rerender on actionSupport's finish.
<apex:selectList id="birthPlace" value="{!birthPlace}">
<apex:selectOption itemLabel="--None--" itemValue="none" />
<apex:selectOption itemLabel="Poland" itemValue="pld" />
<apex:selectOption itemLabel="Europe" itemValue="erp" />
<apex:actionSupport event="onchange" action="{!boolChange}" rerender="nameFields" />
</apex:selectList>
<apex:outputPanel id="nameFields">
<apex:outputField label="Name" value="{!Chopin}" rendered="{!pianoBool}" />
<apex:inputField label="Name" value="{!Chopin}" rendered="{!NOT(pianoBool)}" />
</apex:outputPanel>
Hope it helps!
The way you are getting the field description is Ok:
/services/data/v29.0/sobjects/account/describe
If you check in the official doc you'll see
nillable boolean Indicates whether the field is nillable (true) or not
(false). A nillable field can have empty content. A non-nillable field
must have a value in order for the object to be created or saved.
I've checked Account.Name and nillable seems to be Ok:
"name" : "Account",
"fields" : [ {
...
"name" : "Name",
"nillable" : false,
Also, I've tried two custom fields an the result are Ok:
...
"name" : "TestReq__c",
"nillable" : false,
...
"name" : "TestNoReq__c",
"nillable" : true,
Are you sure that your API response are getting the wrong value? Are you working with PersonAccounts?
Updated
In addition (By reading Jonathan answer) I notice, you could also check if the pageLayout using the same REST API:
/services/data/v29.0/sobjects/Account/describe/layouts
You will get there the layouts for that object where will find the layoutItem
object which contains the require
attr.
However, I think that you are trying to insert/update data through API and hence those security controls are expected to be omitted
Best Answer
This is a
isNillable()
method of theDescribeFieldResult
Schema class:Read more about all methods here: DescribeFieldResult Class
And here are related posts: