You need to sign in to do that
Don't have an account?
sansha
Rerendering issue while making an input fields required attribute true
I need to show to the user if a field is mandatory or not. Hence I set the required attribute of the inputfield to true. However I see that on doing this the page rerendering does not take place unless one enters all the fields having required attribute as true.
Is there a work around ? I need to display the red mark before the field in order to indicate that the field is mandatory. Is it possible to achieve this without setting the required attribute of the input field to true ?
http://blog.jeffdouglas.com/2008/11/16/displaying-the-required-red-bar-for-a-control/
Jeff Douglas
Informa Plc
blog.jeffdouglas.com
<apex:outputLabel value="FieldLabel" for="ip1"/>
<apex:outputPanel styleclass="requiredInput">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Table1__c.field1__c}" id="ip1"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
If your fields are already set as required in the custom field definition and you're inside of a pageBlock, they should appear as required automatically. Likewise if you set them to required="true" inside of a pageBlock you should see the required bar and they will be validated on a post. The only time you have to create the red bar yourself is if you are using inputText or you're outside of a pageBlock. If you're just surrounding a field that's not required via the custom field definition with some CSS, it's never actually going to be validated for requiredness and your users will be able to save your page without entering all of the required fields.
If you are having problems with certain fields getting validated for requiredness during certain form posts, then search around the forums a bit because this question has been answered a lot. You can either use the immediate="true" attribute on your action component or you can use actionRegion to specify only a certain region on the page that you want to be posted.
<apexutputLabel value="FieldLabel" for="ip1"/>
<apexutputPanel styleclass="requiredInput">
<apexutputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Table1__c.field1__c}" id="ip1"/>
</apexutputPanel>
</apexageblockSectionItem>
The solution is either the immediate attribute on your action component, or the use of actionRegion to control your form post. This has been discussed in several threads on these forums.
I will have a look at the actionRegion to control form post.
In the meanwhile I want to know how to set the width of the field label. A single column in the the pageBlockSection spans two cells - one for the field's label and one for its value. I want to set the width differently for each of these cells.