Fix FIXME in functions/addressbook.php
[squirrelmail.git] / functions / forms.php
index feefdadbd9c1ba43dafea036fbbc8cf0d1060136..361dd49db93299514d1f3b483e640af67dcce434 100644 (file)
@@ -24,7 +24,7 @@
  * @link http://www.section508.gov/ Section 508
  * @link http://www.w3.org/WAI/ Web Accessibility Initiative (WAI)
  * @link http://www.w3.org/TR/html4/ W3.org HTML 4.01 form specs
- * @copyright © 2004-2005 The SquirrelMail Project Team
+ * @copyright © 2004-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -50,7 +50,15 @@ function addInputField($sType, $aAttribs=array()) {
     $sAttribs = '';
     // define unique identifier
     if (! isset($aAttribs['id']) && isset($aAttribs['name']) && ! is_null($aAttribs['name'])) {
-        $aAttribs['id'] = $aAttribs['name'];
+        /**
+         * if 'id' is not set, set it to 'name' and replace brackets 
+         * with underscores. 'name' might contain field name with squire
+         * brackets (array). Brackets are not allowed in id (validator.w3.org
+         * fails to validate document). According to html 4.01 manual cdata 
+         * type description, 'name' attribute uses same type, but validator.w3.org 
+         * does not barf on brackets in 'name' attributes.
+         */
+        $aAttribs['id'] = strtr($aAttribs['name'],'[]','__');
     }
     // create attribute string (do we have to sanitize keys?)
     foreach ($aAttribs as $key => $value) {
@@ -291,5 +299,3 @@ function addForm($sAction, $sMethod = 'post', $sName = '', $sEnctype = '', $sCha
     return '<form action="'. $sAction .'" method="'. $sMethod .'"'.
         $sEnctype . $sName . $sCharset . $sAttribs . ">\n";
 }
-
-?>
\ No newline at end of file