Domcrawler error -> Malformed field path

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

Post Reply
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Domcrawler error -> Malformed field path

Post 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...
Newbie The Passion for Learning
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Domcrawler error -> Malformed field path

Post by Christopher »

I assume this is in the HTML form field. If so try:[quote="Grandong"]

Code: Select all

name="guestTypes[0][amount]"
(#10850)
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Re: Domcrawler error -> Malformed field path

Post 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...
Last edited by Grandong on Fri Oct 30, 2015 4:03 pm, edited 1 time in total.
Newbie The Passion for Learning
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Domcrawler error -> Malformed field path

Post 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.
(#10850)
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Re: Domcrawler error -> Malformed field path

Post 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 :(

Code: Select all

Undefined variable: guestTypes
Newbie The Passion for Learning
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Domcrawler error -> Malformed field path

Post by Christopher »

It is not clear where the value is coming from. Perhaps dump the contents of $search and $_REQUEST?
(#10850)
Post Reply