@@ -7299,92 +7299,53 @@ public function testHtml5InputException() {
7299
7299
}
7300
7300
7301
7301
/**
7302
- * Tests that the 'on' key validates as expected on create
7302
+ * Tests that formhelper sets required attributes.
7303
7303
*
7304
7304
* @return void
7305
7305
*/
7306
- public function testRequiredOnCreate () {
7307
- $ this ->markTestIncomplete ('Need to revisit once models work again. ' );
7308
- $ this ->Form ->create ('Contact ' );
7309
-
7310
- $ result = $ this ->Form ->input ('Contact.imrequiredonupdate ' );
7311
- $ expected = array (
7312
- 'div ' => array ('class ' => 'input text ' ),
7313
- 'label ' => array ('for ' => 'ContactImrequiredonupdate ' ),
7314
- 'Imrequiredonupdate ' ,
7315
- '/label ' ,
7316
- 'input ' => array (
7317
- 'type ' => 'text ' , 'name ' => 'Contact[imrequiredonupdate] ' ,
7318
- 'id ' => 'ContactImrequiredonupdate '
7319
- ),
7320
- '/div '
7321
- );
7322
- $ this ->assertTags ($ result , $ expected );
7306
+ public function testRequiredAttribute () {
7307
+ $ this ->article ['required ' ] = [
7308
+ 'title ' => true ,
7309
+ 'body ' => false ,
7310
+ ];
7311
+ $ this ->Form ->create ($ this ->article );
7323
7312
7324
- $ result = $ this ->Form ->input ('Contact.imrequiredoncreate ' );
7313
+ $ result = $ this ->Form ->input ('title ' );
7325
7314
$ expected = array (
7326
7315
'div ' => array ('class ' => 'input text required ' ),
7327
- 'label ' => array ('for ' => 'ContactImrequiredoncreate ' ),
7328
- 'Imrequiredoncreate ' ,
7316
+ 'label ' => array ('for ' => 'title ' ),
7317
+ 'Title ' ,
7329
7318
'/label ' ,
7330
7319
'input ' => array (
7331
- 'type ' => 'text ' , 'name ' => 'Contact[imrequiredoncreate] ' ,
7332
- 'id ' => 'ContactImrequiredoncreate ' ,
7333
- 'required ' => 'required '
7320
+ 'type ' => 'text ' ,
7321
+ 'name ' => 'title ' ,
7322
+ 'id ' => 'title ' ,
7323
+ 'required ' => 'required ' ,
7334
7324
),
7335
7325
'/div '
7336
7326
);
7337
7327
$ this ->assertTags ($ result , $ expected );
7338
7328
7339
- $ result = $ this ->Form ->input ('Contact.imrequiredonboth ' );
7340
- $ expected = array (
7341
- 'div ' => array ('class ' => 'input text required ' ),
7342
- 'label ' => array ('for ' => 'ContactImrequiredonboth ' ),
7343
- 'Imrequiredonboth ' ,
7344
- '/label ' ,
7345
- 'input ' => array (
7346
- 'type ' => 'text ' , 'name ' => 'Contact[imrequiredonboth] ' ,
7347
- 'id ' => 'ContactImrequiredonboth ' ,
7348
- 'required ' => 'required '
7349
- ),
7350
- '/div '
7351
- );
7352
- $ this ->assertTags ($ result , $ expected );
7329
+ $ result = $ this ->Form ->input ('title ' , ['required ' => false ]);
7330
+ $ this ->assertNotContains ('required ' , $ result );
7353
7331
7354
- $ this ->Form ->inputDefaults (array ('required ' => false ));
7355
- $ result = $ this ->Form ->input ('Contact.imrequired ' );
7332
+ $ result = $ this ->Form ->input ('body ' );
7356
7333
$ expected = array (
7357
7334
'div ' => array ('class ' => 'input text ' ),
7358
- 'label ' => array ('for ' => 'ContactImrequired ' ),
7359
- 'Imrequired ' ,
7335
+ 'label ' => array ('for ' => 'body ' ),
7336
+ 'Body ' ,
7360
7337
'/label ' ,
7361
7338
'input ' => array (
7362
- 'type ' => 'text ' , 'name ' => 'Contact[imrequired] ' ,
7363
- 'id ' => 'ContactImrequired '
7364
- ),
7365
- '/div '
7366
- );
7367
- $ this ->assertTags ($ result , $ expected );
7368
-
7369
- $ result = $ this ->Form ->input ('Contact.imrequired ' , array ('required ' => false ));
7370
- $ this ->assertTags ($ result , $ expected );
7371
-
7372
- $ result = $ this ->Form ->input ('Contact.imrequired ' , array ('required ' => true ));
7373
- $ expected = array (
7374
- 'div ' => array ('class ' => 'input text required ' ),
7375
- 'label ' => array ('for ' => 'ContactImrequired ' ),
7376
- 'Imrequired ' ,
7377
- '/label ' ,
7378
- 'input ' => array (
7379
- 'required ' => 'required ' , 'type ' => 'text ' , 'name ' => 'data[Contact][imrequired] ' ,
7380
- 'id ' => 'ContactImrequired '
7339
+ 'type ' => 'text ' ,
7340
+ 'name ' => 'body ' ,
7341
+ 'id ' => 'body ' ,
7381
7342
),
7382
7343
'/div '
7383
7344
);
7384
7345
$ this ->assertTags ($ result , $ expected );
7385
7346
7386
- $ result = $ this ->Form ->input ('Contact.imrequired ' , array ( 'required ' => null ) );
7387
- $ this ->assertTags ( $ result , $ expected );
7347
+ $ result = $ this ->Form ->input ('body ' , [ 'required ' => true ] );
7348
+ $ this ->assertContains ( ' required ' , $ result );
7388
7349
}
7389
7350
7390
7351
/**
0 commit comments