@@ -1865,6 +1865,60 @@ public function testEmptyInputErrorValidation() {
1865
1865
$ this ->assertHtml ($ expected , $ result );
1866
1866
}
1867
1867
1868
+ /**
1869
+ * Test validation errors, when calling input() overriding validation messages
1870
+ *
1871
+ * @return void
1872
+ */
1873
+ public function testInputErrorMessage () {
1874
+ $ this ->article ['errors ' ] = [
1875
+ 'title ' => ['error message ' ]
1876
+ ];
1877
+ $ this ->Form ->create ($ this ->article );
1878
+
1879
+ $ result = $ this ->Form ->input ('title ' , [
1880
+ 'error ' => 'Custom error! '
1881
+ ]);
1882
+ $ expected = [
1883
+ 'div ' => ['class ' => 'input text required error ' ],
1884
+ 'label ' => ['for ' => 'title ' ],
1885
+ 'Title ' ,
1886
+ '/label ' ,
1887
+ 'input ' => [
1888
+ 'type ' => 'text ' , 'name ' => 'title ' ,
1889
+ 'id ' => 'title ' , 'class ' => 'form-error ' ,
1890
+ 'required ' => 'required ' ,
1891
+ ],
1892
+ ['div ' => ['class ' => 'error-message ' ]],
1893
+ 'Custom error! ' ,
1894
+ '/div ' ,
1895
+ '/div '
1896
+ ];
1897
+ $ this ->assertHtml ($ expected , $ result );
1898
+
1899
+ $ result = $ this ->Form ->input ('title ' , [
1900
+ 'error ' => ['error message ' => 'Custom error! ' ]
1901
+ ]);
1902
+ $ expected = [
1903
+ 'div ' => ['class ' => 'input text required error ' ],
1904
+ 'label ' => ['for ' => 'title ' ],
1905
+ 'Title ' ,
1906
+ '/label ' ,
1907
+ 'input ' => [
1908
+ 'type ' => 'text ' ,
1909
+ 'name ' => 'title ' ,
1910
+ 'id ' => 'title ' ,
1911
+ 'class ' => 'form-error ' ,
1912
+ 'required ' => 'required '
1913
+ ],
1914
+ ['div ' => ['class ' => 'error-message ' ]],
1915
+ 'Custom error! ' ,
1916
+ '/div ' ,
1917
+ '/div '
1918
+ ];
1919
+ $ this ->assertHtml ($ expected , $ result );
1920
+ }
1921
+
1868
1922
/**
1869
1923
* Tests displaying errors for nested entities
1870
1924
*
0 commit comments