ラベル

2021-08-27

Salesforce - Visualforce - apex:input


apex:input のメモ書き
  • 任意の日付型の入力項目を表示する(入力値の最大値・最小値の制限も加える)





■ type : date 

VFPage

<apex:page docType="html-5.0" StandardController="Contact" extensions="SampleController">

<apex:input label="日付" type="date" value="{!sampleDate}" html-min="{!sampleMinDate}" html-max="{!sampleMaxDate}"  />

</apex:page>

※ 「type 属性」を使うには「apex:page コンポーネント」の「docType 属性」を指定する
※ 「html-min 属性」「html-max 属性」はパススルー属性

Apex

public class SampleController {

	public Date sampleDate { get; set; }
	public String sampleMinDate { get; private set; }
	public String sampleMaxDate { get; private set; }

	public SampleController(ApexPages.StandardController controller) {

		this.sampleMinDate = String.valueOf(System.today());
		this.sampleMaxDate = String.valueOf(System.today().addYears(1));

	}
}



ref: