@@ -90,6 +90,33 @@ test('prompt + required', function () {
9090 Assert::same ('<select name="list" id="frm-list" required data-nette-rules= \'[{"op":":filled","msg":"This field is required."}] \'><option value="" disabled hidden>prompt</option><option value="a">First</option><option value="0" selected>Second</option></select> ' , (string ) $ input ->getControl ());
9191});
9292
93+ test ('prompt + checkDefaultValueToFalse + value does not exist ' , function () {
94+ $ form = new Form ;
95+ $ input = $ form ->addSelect ('list ' , 'Label ' , [
96+ 'a ' => 'First ' ,
97+ 0 => 'Second ' ,
98+ ])->setPrompt ('prompt ' )->checkDefaultValue (false );
99+
100+ Assert::same ('<select name="list" id="frm-list"><option value="">prompt</option><option value="a">First</option><option value="0">Second</option></select> ' , (string ) $ input ->getControl ());
101+
102+ $ input ->setValue ('does not exists ' );
103+
104+ Assert::same ('<select name="list" id="frm-list"><option value="">prompt</option><option value="a">First</option><option value="0">Second</option></select> ' , (string ) $ input ->getControl ());
105+ });
106+
107+ test ('prompt + required + checkDefaultValueToFalse + value does not exist ' , function () {
108+ $ form = new Form ;
109+ $ input = $ form ->addSelect ('list ' , 'Label ' , [
110+ 'a ' => 'First ' ,
111+ 0 => 'Second ' ,
112+ ])->setPrompt ('prompt ' )->setRequired ()->checkDefaultValue (false );
113+
114+ Assert::same ('<select name="list" id="frm-list" required data-nette-rules= \'[{"op":":filled","msg":"This field is required."}] \'><option value="" disabled hidden selected>prompt</option><option value="a">First</option><option value="0">Second</option></select> ' , (string ) $ input ->getControl ());
115+
116+ $ input ->setValue ('does not exists ' );
117+
118+ Assert::same ('<select name="list" id="frm-list" required data-nette-rules= \'[{"op":":filled","msg":"This field is required."}] \'><option value="" disabled hidden selected>prompt</option><option value="a">First</option><option value="0">Second</option></select> ' , (string ) $ input ->getControl ());
119+ });
93120
94121test ('unique prompt ' , function () {
95122 $ form = new Form ;
0 commit comments