[SalesForce] How to remove required field validation in a Visualforce page

This is driving me crazy!!

I have a very simple page with checkbox and textfield (start_date__c) if the checkbox is checked then the textfield is required so far so good no problem, the start_date__c is required field.

Screen shot 1 Without check:

enter image description here

Screen shot 2 Checked:

enter image description here

But when I submit the page without is Present checked then i'm getting this error:

Start Date required field is missing

I do not have validation rule that specific field but my question is why is it complaining when the required field is = false in the visualforce page

  <apex:inputField value="{!employee__c.Start_Date__c}" required="false"/>

Best Answer

Nick,

The main problem (per your comments) is that the field is required at the object level. When you make a field required like that, you cannot save a blank value in there in any way (API, code, standard layout).

As Adrian mentioned, you can choose several workarounds.

1) You can make a smart Validation Rule

This will allow you to bypass the requirement in certain cases

2) You can make it required at a Page Layout level

This will let you save blank values via VF or API, but maintain the requirement of the field for people using the standard Page Layout.

3) You can write a trigger

Please don't do it, either of the two cases above should be enough in a simple case like this. :D