I have multiple sections on page. I am rendering these sections using a list. I want fields in first section to be required only. so I have used an apex:variable which I am incrementing within apex:repeat. I have used condition with apex:inpufield required attribute.

<apex:inputfield value="{!obj[myInfo.fieldPath]}" required="{!IF(srNo==1 ,true,false)}"/>

with this condition I am getting red bar in front of the field but on submitting the page, it is not validating that field. why this is happening?

  • How are you surfacing srNo? May 7 '13 at 11:08
  • i am using it in repeat as apex:variable
    – Pankaj
    May 7 '13 at 11:24
  • Do you have immediate="true" on your submit button? May 7 '13 at 11:55
  • No. i do not have immediate="true". i have few other fields on the page also, they are validating accordingly.
    – Pankaj
    May 7 '13 at 12:08
  • 1
    Are you using a Standard Controller with a custom extension, or a custom controller? May 7 '13 at 12:49

This sounds like it might be a bug. If you're seeing the red bar next to the right fields you can safely assume that the required flag is getting set correctly.

Things that override field requirements to consider:

Immediate Flag

If you set the immediate attribute of the any action element (i.e. commandButton) to true the action method will execute before any validations and the required field gets ignored.

Action Region

If you're using an apex:actionRegion tag only data within that tag is getting sent to the controller in the post back and the required field check won't occur

Non-Standard Submit

If you're submit action occurs via a webservice or apex remoting it's bypassing the usual form submit and the required field check.


If nothing else is making sense it may just be a bug in the platform. You can submit a case to support, but it's probably a lot quicker just to enforce the check yourself in the controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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