File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
4
+ 4.4.0
5
+ -----
6
+
7
+ * Added ` Form::getName() ` method.
8
+
4
9
4.3.0
5
10
-----
6
11
Original file line number Diff line number Diff line change @@ -250,6 +250,16 @@ public function getMethod()
250
250
return $ this ->node ->getAttribute ('method ' ) ? strtoupper ($ this ->node ->getAttribute ('method ' )) : 'GET ' ;
251
251
}
252
252
253
+ /**
254
+ * Gets the form name.
255
+ *
256
+ * If no name is defined on the form, an empty string is returned.
257
+ */
258
+ public function getName (): string
259
+ {
260
+ return $ this ->node ->getAttribute ('name ' );
261
+ }
262
+
253
263
/**
254
264
* Returns true if the named field exists.
255
265
*
Original file line number Diff line number Diff line change @@ -327,6 +327,18 @@ public function testGetMethodWithOverride()
327
327
$ this ->assertEquals ('POST ' , $ form ->getMethod (), '->getMethod() returns the method attribute value of the form ' );
328
328
}
329
329
330
+ public function testGetName ()
331
+ {
332
+ $ form = $ this ->createForm ('<form name="foo"><input type="submit" /></form> ' );
333
+ $ this ->assertSame ('foo ' , $ form ->getName ());
334
+ }
335
+
336
+ public function testGetNameOnFormWithoutName ()
337
+ {
338
+ $ form = $ this ->createForm ('<form><input type="submit" /></form> ' );
339
+ $ this ->assertSame ('' , $ form ->getName ());
340
+ }
341
+
330
342
public function testGetSetValue ()
331
343
{
332
344
$ form = $ this ->createForm ('<form><input type="text" name="foo" value="foo" /><input type="submit" /></form> ' );
You can’t perform that action at this time.
0 commit comments