@@ -283,6 +283,108 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
283
283
);
284
284
}
285
285
286
+ public function testLabelFormatName ()
287
+ {
288
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' )
289
+ ->add ('myfield ' , 'text ' )
290
+ ->getForm ();
291
+ $ view = $ form ->get ('myfield ' )->createView ();
292
+ $ html = $ this ->renderLabel ($ view , null , array ('label_format ' => 'form.%name% ' ));
293
+
294
+ $ this ->assertMatchesXpath ($ html ,
295
+ '/label
296
+ [@for="myform_myfield"]
297
+ [.="[trans]form.myfield[/trans]"]
298
+ '
299
+ );
300
+ }
301
+
302
+ public function testLabelFormatId ()
303
+ {
304
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' )
305
+ ->add ('myfield ' , 'text ' )
306
+ ->getForm ();
307
+ $ view = $ form ->get ('myfield ' )->createView ();
308
+ $ html = $ this ->renderLabel ($ view , null , array ('label_format ' => 'form.%id% ' ));
309
+
310
+ $ this ->assertMatchesXpath ($ html ,
311
+ '/label
312
+ [@for="myform_myfield"]
313
+ [.="[trans]form.myform_myfield[/trans]"]
314
+ '
315
+ );
316
+ }
317
+
318
+ public function testLabelFormatAsFormOption ()
319
+ {
320
+ $ options = array ('label_format ' => 'form.%name% ' );
321
+
322
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' , 'form ' , null , $ options )
323
+ ->add ('myfield ' , 'text ' )
324
+ ->getForm ();
325
+ $ view = $ form ->get ('myfield ' )->createView ();
326
+ $ html = $ this ->renderLabel ($ view );
327
+
328
+ $ this ->assertMatchesXpath ($ html ,
329
+ '/label
330
+ [@for="myform_myfield"]
331
+ [.="[trans]form.myfield[/trans]"]
332
+ '
333
+ );
334
+ }
335
+
336
+ public function testLabelFormatOverriddenOption ()
337
+ {
338
+ $ options = array ('label_format ' => 'form.%name% ' );
339
+
340
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' , 'form ' , null , $ options )
341
+ ->add ('myfield ' , 'text ' , array ('label_format ' => 'field.%name% ' ))
342
+ ->getForm ();
343
+ $ view = $ form ->get ('myfield ' )->createView ();
344
+ $ html = $ this ->renderLabel ($ view );
345
+
346
+ $ this ->assertMatchesXpath ($ html ,
347
+ '/label
348
+ [@for="myform_myfield"]
349
+ [.="[trans]field.myfield[/trans]"]
350
+ '
351
+ );
352
+ }
353
+
354
+ public function testLabelFormatOnButton ()
355
+ {
356
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' )
357
+ ->add ('mybutton ' , 'button ' )
358
+ ->getForm ();
359
+ $ view = $ form ->get ('mybutton ' )->createView ();
360
+ $ html = $ this ->renderWidget ($ view , array ('label_format ' => 'form.%name% ' ));
361
+
362
+ $ this ->assertMatchesXpath ($ html ,
363
+ '/button
364
+ [@type="button"]
365
+ [@name="myform[mybutton]"]
366
+ [.="[trans]form.mybutton[/trans]"]
367
+ '
368
+ );
369
+ }
370
+
371
+ public function testLabelFormatOnButtonId ()
372
+ {
373
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' )
374
+ ->add ('mybutton ' , 'button ' )
375
+ ->getForm ();
376
+ $ view = $ form ->get ('mybutton ' )->createView ();
377
+ $ html = $ this ->renderWidget ($ view , array ('label_format ' => 'form.%id% ' ));
378
+
379
+ $ this ->assertMatchesXpath ($ html ,
380
+ '/button
381
+ [@type="button"]
382
+ [@name="myform[mybutton]"]
383
+ [.="[trans]form.myform_mybutton[/trans]"]
384
+ '
385
+ );
386
+ }
387
+
286
388
public function testErrors ()
287
389
{
288
390
$ form = $ this ->factory ->createNamed ('name ' , 'text ' );
0 commit comments