Page 1 of 1
Domcrawler error -> Malformed field path
Posted: Thu Oct 29, 2015 1:33 pm
by Grandong
i cannot submit form if name using this
Code: Select all
$search['guestTypes[0].amount']='1';
always get error:
Code: Select all
Malformed field path "guestTypes[0].amount"
i try using:
Code: Select all
$html = $crawler->html();
$html = str_replace('[', '%5B', $html);
$html = str_replace(']', '%5D', $html);
$crawler->clear();
$crawler->add($html);
but iam not lucky...
someone help me please...
Re: Domcrawler error -> Malformed field path
Posted: Fri Oct 30, 2015 1:21 pm
by Christopher
I assume this is in the HTML form field. If so try:[quote="Grandong"]
Re: Domcrawler error -> Malformed field path
Posted: Fri Oct 30, 2015 3:45 pm
by Grandong
hi @Christopher
thx very much for u'r reply.
but:
1. i cannot edit name of form field, because this result from scraping site
2. i try using $search['guestTypes[0][amount]']='1'; >> but don't work.. error :
Code: Select all
InvalidArgumentException in FormFieldRegistry.php line 89: Unreachable field "guestTypes"
this my code:
Code: Select all
$crawler = $client->request('GET', $url);
$html = $crawler->html();
$html = str_replace('[', '%5B', $html);
$html = str_replace(']', '%5D', $html);
$crawler->clear();
$crawler->add($html);
$search = $crawler->filterXPath('//form[@id="inputForm"]')->form();
$search->disableValidation();
$search['guestTypes[0][amount]']='1';
$crawler = $client->submit($search);
and
other solution please...
Re: Domcrawler error -> Malformed field path
Posted: Fri Oct 30, 2015 4:03 pm
by Christopher
I am guessing that this is a Symfony or Drupal question. From your code above, maybe try:[syntax]$search[$guestTypes[0].amount] = '1';[/syntax]
You might want to use var_dump() or print_r() to show the contents of $search and $guestTypes. Then you will know what you are dealing with.
Re: Domcrawler error -> Malformed field path
Posted: Fri Oct 30, 2015 4:06 pm
by Grandong
Christopher wrote:I am guessing that this is a Symfony or Drupal question. From your code above, maybe try:[syntax]$search[$guestTypes[0].amount] = '1';[/syntax]
You might want to use var_dump() or print_r() to show the contents of $search and $guestTypes. Then you will know what you are dealing with.
no lucky
Re: Domcrawler error -> Malformed field path
Posted: Sun Nov 01, 2015 11:17 pm
by Christopher
It is not clear where the value is coming from. Perhaps dump the contents of $search and $_REQUEST?