tbirnseth
09-25-2005, 10:37 PM
I'm frustrated! :eek:
I'm managing a configuration file that has (or will) have maybe 100 configuration parameters. I'm trying to use PHP's array types for the names of the form elements. I.e.
<input name="pValue[cfgRootDir]" type="text" value="mypath/config.foo" />
The <input> form elements seem to work fine. However, when the array type for a name is associated with a <select> (either raido buttons or a menu) I get very sporadic (or at least unexpected) behavior. So for instance, the following code segments seem to behave as I'll describe:
This <select> segment for the menu of types (with the "SELECTED" item being correctly selected base on the type of the data) comes into the $_POST as unset (shown through print_r($_POST))! My assumption is that a SELECTED <option> should be passed with the form. Am I correct? Shouldn't it behave in the same way as any other element that has a "value" set (in this case SELECTED)?
<div class="cfgName">
<input type="text" name="pName[cfgDebug]" value="cfgDebug" />
</div> <!-- cfgName -->
<div class="cfgLevel">Core Config
</div> <!-- cfgLevel -->
<div class="cfgType">
<select name="pType[cfgDebug]" id="" >
<option value="1"> string </option>
<option value="2"SELECTED > bool </option>
<option value="3"> int </option>
<option value="4"> path </option>
<option value="5"> prompt </option>
</select>
</div> <!-- cfgType -->
<div class="cfgValue">
<label>
<input type="radio" name="pType[cfgDebug]" value="1"/>True
</label>
<label>
<input type="radio" name="pType[cfgDebug]" value="0"CHECKED
/>False</label>
</div> <!-- cfgValue -->
When the radio button value selection is selected as TRUE, the $_POST['cfgDebug']['pValue'] is coming across as 0 even though the TRUE selection was made.
I'm about ready to scream. Anyone have any experience with this? Is this a PHP problem or an issue with what the browsers are posting?
BTW: if I put a space between the value="name"SELECTED area, FireFox seems to simply not send anything for that form element!
Help?
tony
I'm managing a configuration file that has (or will) have maybe 100 configuration parameters. I'm trying to use PHP's array types for the names of the form elements. I.e.
<input name="pValue[cfgRootDir]" type="text" value="mypath/config.foo" />
The <input> form elements seem to work fine. However, when the array type for a name is associated with a <select> (either raido buttons or a menu) I get very sporadic (or at least unexpected) behavior. So for instance, the following code segments seem to behave as I'll describe:
This <select> segment for the menu of types (with the "SELECTED" item being correctly selected base on the type of the data) comes into the $_POST as unset (shown through print_r($_POST))! My assumption is that a SELECTED <option> should be passed with the form. Am I correct? Shouldn't it behave in the same way as any other element that has a "value" set (in this case SELECTED)?
<div class="cfgName">
<input type="text" name="pName[cfgDebug]" value="cfgDebug" />
</div> <!-- cfgName -->
<div class="cfgLevel">Core Config
</div> <!-- cfgLevel -->
<div class="cfgType">
<select name="pType[cfgDebug]" id="" >
<option value="1"> string </option>
<option value="2"SELECTED > bool </option>
<option value="3"> int </option>
<option value="4"> path </option>
<option value="5"> prompt </option>
</select>
</div> <!-- cfgType -->
<div class="cfgValue">
<label>
<input type="radio" name="pType[cfgDebug]" value="1"/>True
</label>
<label>
<input type="radio" name="pType[cfgDebug]" value="0"CHECKED
/>False</label>
</div> <!-- cfgValue -->
When the radio button value selection is selected as TRUE, the $_POST['cfgDebug']['pValue'] is coming across as 0 even though the TRUE selection was made.
I'm about ready to scream. Anyone have any experience with this? Is this a PHP problem or an issue with what the browsers are posting?
BTW: if I put a space between the value="name"SELECTED area, FireFox seems to simply not send anything for that form element!
Help?
tony