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 11CHANGELOG
22=========
33
4+ 4.4.0
5+ -----
6+
7+ * Added ` Form::getName() ` method.
8+
494.3.0
510-----
611
Original file line number Diff line number Diff line change @@ -250,6 +250,16 @@ public function getMethod()
250250 return $ this ->node ->getAttribute ('method ' ) ? strtoupper ($ this ->node ->getAttribute ('method ' )) : 'GET ' ;
251251 }
252252
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+
253263 /**
254264 * Returns true if the named field exists.
255265 *
Original file line number Diff line number Diff line change @@ -327,6 +327,18 @@ public function testGetMethodWithOverride()
327327 $ this ->assertEquals ('POST ' , $ form ->getMethod (), '->getMethod() returns the method attribute value of the form ' );
328328 }
329329
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+
330342 public function testGetSetValue ()
331343 {
332344 $ 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