You need to sign in to do that
Don't have an account?
shra1_dev
date selector in vf page
Hi,
how to get date selector beside a field of type date in vf page.
for example:
fromDate | [ 10/20/2010 ] |
it could be possible with <apex:inputfield/>(it will come automatically) but i am not using the same standard controller in the page.
here the fromdate field's object is different from the object mentioned in the standardcontroller.
Hello
Its my mistake. I had to put the inputField value as
In your case the input field should be as below because your method name is getfromDate(). Sorry for the mistake.
All Answers
Hello it is no matter what your standard controller is.
For an example lets think your standard controller is Account and you need to display the 'closeDate' field which belongs to Opportunity sObject.
In your Controller method you have to return the Opportunity instead of returning the 'closeDate' field(See below).
Now in your VF page, access the closeDate fields as below.
Now you will get the datePicker window.
Thanks for quick reply....I hav done wat u hav suggested...
But i am getting an error as
i hav written the code as:
/* visual force*/
<apex:page standardController="UserProfile__c" extensions="LeaveAppClass">
<apex:form >
fromdate : <apex:inputField value="{!date.fromDate}"/>
</apex:form>
</apex:page>
/*controller*/
public LeaveApp__c getfromDate()
{
LeaveApp__c lcon = [select fromDate__c from LeaveApp__c LIMIT 1];
return lcon;
}
where am i doing the mistake...please help me
Hello
Its my mistake. I had to put the inputField value as
In your case the input field should be as below because your method name is getfromDate(). Sorry for the mistake.
thanks prageeth.......
it is working but on page load it should not diplay the value in it . can't we make that field to empty on page load.
Hello shra1_dev;
Could you please explain it little more.
If you don't want to display the value at page load, then at what time do you want to display the value?
After a button click or etc...
Hi prageeth,
In the fromDate field it is showing the value of fromDate of the first record in the LeaveApp object.
It should not show that value . it should be empty by default. then the user should select the date from Datepicker.
It is required because i am placing another field toDate which could be empty.
If it is not empty at page load the user needs to delete the content in toDate field every time he visits the page(If he doesn't want to mention toDate)