« Return to Thread: Zend_Form_Element_Image

Re: Re: Zend_Form_Element_Image

by Bryce Lohr-2 :: Rate this Message:

Reply to Author | View in Thread

As I understand it, PHP is actually translating the periods in form field names to underscores; presumably to ensure they're valid PHP identifiers. Try this form in any browser (GET or POST):

<html>
<body>
<h1>PHP Translates Dots to Underscores</h1>
<pre><?php var_dump($_REQUEST); ?></pre>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
    First name: <input name="customer.first_name">
    Last name: <input name="customer.last_name">
    <input type="submit" value="Submit">
</form>
</body>
</html>

The dots between the table and field name always end up as underscores in the var_dump, but are submitted as dots by the browser. I seem to remember this giving me a headache back in PHP 4. Would be nice if we could turn that behaviour off...

Regards,
Bryce Lohr


Matthew Weier O'Phinney wrote:
-- Simon Mundy simon.mundy@... wrote
(on Friday, 09 May 2008, 02:15 PM +1000):
  
I've just noticed I've been having a lot of trouble trying to identity  
elements of a type Zend_Form_Element_Image with the isChecked() method. 
From what I can tell, the parent form attempts to validate the element by 
matching the form data key with the element's name. However with image 
form submission, all element keys have the '_x' and '_y' appended to 
them, so that means that the image will never be validated.
    

Ugh. The W3C says that they should be submitted as <name>.x (not _x) and
<name>.y... but an interesting thing is that different browsers handle
them differently. When I tested originally on FF, it was submitting
three values -- <name> (with the value attributed to the element),
<name>_x (with the X coordinate where the image was clicked), and
<name>_y (with the Y coordinate where the image was clicked) -- so using
just the element name worked fine. Evidently, this isn't true for all
browsers -- and I should not have assumed so, knowing that FF differred
from the W3C.

Obviously, we need better detection, and this logic should likely be in
the form layer (not the element). Could you put an issue in the tracker
for this?

  

 « Return to Thread: Zend_Form_Element_Image