Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Is there a way to conditionally render an apex:inputField only if the field exists on the running org?

I tried the following syntax but always ran into errors:

<apex:inputField value="{!CustomObject__c['optionalField__c']}" />
<apex:inputField value="{!CustomObject__c['optionalField']}"  
   rendered="{!NOT(ISNULL($ObjectType.CustomObject__c.fields['optionalField__c']))}" />
share|improve this question
    
as far as I know, you can't, inputfields are hard-bound to an sobject field which must exist in the org, else you will fail on saving. You could potentially make workarounds with normal HTML, and javascript/css, combined with extension variables, but this is quite a hassle. –  PJC Jan 31 '13 at 9:47
add comment

1 Answer

up vote 5 down vote accepted

I didn't find any solution for this but I think as per your requirement you should use "FieldSets" and use that FieldSet to render fields on you visualforce page.

Here you can find FieldSet information.

I am suggesting this to you because i am using this and rendering the input fields based on some condition and it is working fine.

share|improve this answer
    
How come that this doesn't work for the RecordType field? –  Robert Sösemann Feb 2 '13 at 2:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.