Setup ---> Customize ---> Objects ---> Page Layouts ---> Edit the page layout ---> Select the field you want to make read-only ---> Click on 'Properties' of the field(an icon to the right end of field) ---> Here you will get a checkbox to make the field read only.
Another way to make the field read only is -
Setup ---> Customize ---> Objects ---> Fields ---> Click on the field you want to make read-only ---> Click on button 'Set field-level security' ---> here make the field read only for the profiles you want.
note: Formula fields are always calculated, and therefore always read-only.
if you are using apex:inputfield then it will redirect from the Fieldlevel security of that field go to Setup ---> Customize ---> Objects ---> Fields ---> Click on the field you want to make read-only ---> Click on button 'Set field-level security' ---> here make the field read only for the profiles you want. Also still you can disable that field using disabled="true"
if you are displaying the field in detail mode then you can use outputField
<apex:outputField value="{!Account.Name}" />
Also you can use Javascript to make any input field as readonly
You have to use the <apex:page> as the starting tag. inside the <apex:page> you need to define the <apex:form> tag. hope this link will give you more detail about this tag.
Please use your field name instead of inputValue in this line <apex:inputtext value="{!inputvalue}" html-readonly="true"/><!-- inputvalue replace as your field name-->
iyou can use your controller variable/property or field api name in place of inputvalue.
it would be great if you can post your visualforce code and controller code and i can make appropriate changes and will revert back toyou. from your above reply, there from_class__c is not a property in controller. I think you should use {!a.from_class__c} instead of only {!from_class__C}
Error: Invalid field type for SObject Student__c VF page <apex:page controller="Movestudent" sidebar="false" showHeader="false"> <apex:form > <apex:pageBlock >
<apex:pageBlockTable value="{!students}" var="a" cellPadding="4" border="1"> <apex:column> <apex:inputtext value="{!a.From_Class__c}" html-readonly="true"/><!-- inputvalue replace as your field name--> </apex:column> <apex:column value="{!a.Name}"/> <apex:column value="{!a.type}"/> <apex:column value="{!a.DOB__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Apex class
public class Movestudent{ List<Student__c> students=[select Name,Roll_Number__c,DOB__c,From_Class__c from Student__c]; public List<Student__c > getstudents(){ return students; } }
You can use output field tag instead of using inputfield tag, which will display the field as readonly in visualforce page.
let me know if you have any questions.
Regards,
Sai Krishna Tavva
You can try the <apex:outputField tag for same.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputField.htm
Let us know if this will help you
Thanks
Amit Chaudhary
To make this field read-only, Click on
Setup ---> Customize ---> Objects ---> Page Layouts ---> Edit the page layout ---> Select the field you want to make read-only ---> Click on 'Properties' of the field(an icon to the right end of field) ---> Here you will get a checkbox to make the field read only.
Another way to make the field read only is -
Setup ---> Customize ---> Objects ---> Fields ---> Click on the field you want to make read-only ---> Click on button 'Set field-level security' ---> here make the field read only for the profiles you want.
note: Formula fields are always calculated, and therefore always read-only.
Hope this helps you!
Best Regards,
Jyothsna
if you are usng Apex:inputtext in your visualforce page then use below code
if you are using apex:inputfield then it will redirect from the Fieldlevel security of that field
go to Setup ---> Customize ---> Objects ---> Fields ---> Click on the field you want to make read-only ---> Click on button 'Set field-level security' ---> here make the field read only for the profiles you want.
Also still you can disable that field using disabled="true"
if you are displaying the field in detail mode then you can use outputField
Also you can use Javascript to make any input field as readonly
Please do let me know if it helps you.
Thanks,
Debasis
i have tried but error coming .please check once.
You have to use the <apex:page> as the starting tag. inside the <apex:page> you need to define the <apex:form> tag. hope this link will give you more detail about this tag.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm
Also above code is the markup which you have to modify the code
Regards,
Sai Krishna Tavva.
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!students}" var="a" cellPadding="4" border="1">
<inputText="From Class" readonly="true"/>
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Roll_Number__c}"/>
<apex:column value="{!a.DOB__c }"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
in your previous code you git error because youe apex:form tag is on top of the apex:page tag, apex:page tag should be the top most markup.
try this below code
Still its giving error
Please use your field name instead of inputValue in this line
<apex:inputtext value="{!inputvalue}" html-readonly="true"/><!-- inputvalue replace as your field name-->
iyou can use your controller variable/property or field api name in place of inputvalue.
Thanks,
Debasis
I forgot to change that field name,However after changing the field name still the read only field not coming.
it would be great if you can post your visualforce code and controller code and i can make appropriate changes and will revert back toyou. from your above reply, there from_class__c is not a property in controller. I think you should use {!a.from_class__c} instead of only {!from_class__C}
please post code i will take a look.
Error: Invalid field type for SObject Student__c
VF page
<apex:page controller="Movestudent" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!students}" var="a" cellPadding="4" border="1">
<apex:column>
<apex:inputtext value="{!a.From_Class__c}" html-readonly="true"/><!-- inputvalue replace as your field name-->
</apex:column>
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.type}"/>
<apex:column value="{!a.DOB__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class
public class Movestudent{
List<Student__c> students=[select Name,Roll_Number__c,DOB__c,From_Class__c from Student__c];
public List<Student__c > getstudents(){
return students;
}
}