PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Grandong
Forum Commoner
Posts: 65 Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:
Post
by Grandong » Thu Oct 29, 2015 1:33 pm
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...
Newbie The Passion for Learning
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Oct 30, 2015 1:21 pm
I assume this is in the HTML form field. If so try:[quote="Grandong"]
(#10850)
Grandong
Forum Commoner
Posts: 65 Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:
Post
by Grandong » Fri Oct 30, 2015 3:45 pm
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...
Last edited by
Grandong on Fri Oct 30, 2015 4:03 pm, edited 1 time in total.
Newbie The Passion for Learning
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Oct 30, 2015 4:03 pm
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.
(#10850)
Grandong
Forum Commoner
Posts: 65 Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:
Post
by Grandong » Fri Oct 30, 2015 4:06 pm
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
Newbie The Passion for Learning
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Sun Nov 01, 2015 11:17 pm
It is not clear where the value is coming from. Perhaps dump the contents of $search and $_REQUEST?
(#10850)