@@ -183,7 +183,7 @@ instance with just the selected link(s). Calling ``link()`` gives us a special
183
183
184
184
$linksCrawler = $crawler->selectLink('Go elsewhere...');
185
185
$link = $linksCrawler->link();
186
-
186
+
187
187
// or do this all at once
188
188
$link = $crawler->selectLink('Go elsewhere...')->link();
189
189
@@ -213,7 +213,7 @@ a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the
213
213
form that the button lives in::
214
214
215
215
$form = $crawler->selectButton('validate')->form();
216
-
216
+
217
217
// or "fill" the form fields with data
218
218
$form = $crawler->selectButton('validate')->form(array(
219
219
'name' => 'Ryan',
@@ -223,7 +223,7 @@ The :class:`Symfony\\Component\\DomCrawler\\Form` object has lots of very
223
223
useful methods for working with forms:
224
224
225
225
$uri = $form->getUri();
226
-
226
+
227
227
$method = $form->getMethod();
228
228
229
229
The :method: `Symfony\\ Component\\ DomCrawler\\ Form::getUri ` method does more
@@ -245,12 +245,31 @@ You can virtually set and get values on the form::
245
245
// returns the values like PHP would see them, where "registration" is its own array
246
246
$values = $form->getPhpValues();
247
247
248
+ To work with multi-dimensional fields::
249
+
250
+ <form>
251
+ <input name="multi[]" />
252
+ <input name="multi[]" />
253
+ <input name="multi[dimensional]" />
254
+ </form>
255
+
256
+ You must specify the fully qualified name of the field::
257
+
258
+ // Set a single field
259
+ $form->setValue('multi[0]', 'value');
260
+
261
+ // Set multiple fields at once
262
+ $form->setValue('multi', array(
263
+ 1 => 'value',
264
+ 'dimensional' => 'an other value'
265
+ ));
266
+
248
267
This is great, but it gets better! The ``Form `` object allows you to interact
249
268
with your form like a browser, selecting radio values, ticking checkboxes,
250
269
and uploading files::
251
270
252
271
$form['registration[username]']->setValue('symfonyfan');
253
-
272
+
254
273
// check or uncheck a checkbox
255
274
$form['registration[terms]']->tick();
256
275
$form['registration[terms]']->untick();
@@ -278,7 +297,7 @@ of the information you need to create a POST request for the form::
278
297
$method = $form->getMethod();
279
298
$values = $form->getValues();
280
299
$files = $form->getFiles();
281
-
300
+
282
301
// now use some HTTP client and post using this information
283
302
284
303
One great example of an integrated system that uses all of this is `Goutte `_.
0 commit comments