Jason - under the general subject of 'help with some code', can you please explain to me this line of code? It's taken from a radio button group created with DB:
if (array_search("1", ((isset($_GET["invalid"]) && ValidatedField("projectsupdate","display"))?ValidatedField("projectsupdate","display"):array())) !== false
My interpretation of this is the following - just tell me if I am correct.
When a field fails validation, the form needs to know whether to display the data in the database or the newly submitted data as the page refreshes and to do that the form submits to itself with a url variable of "invalid". So that line is testing whether it's the current field that failed validation or not (in this case that field is named 'display'). If it did fail validation, then the database data is shown, and if it did not fail validation then the (valid) submitted data is shown. I think I have that right....
What puzzles me is that the false part of the ternary operator is just an empty array. Why is that?
So, breaking it down:
isset($_GET['invalid']) - this is true when there is a field in the posted data that fails validation.
ValidatedField("projectsupdate","display") - I'm not exactly sure what this does, but it's always null for this 'display' field.
in this case, these two tests both fail, meaning that the ternary isset($_GET["invalid"]) && ValidatedField("projectsupdate","display"))?ValidatedField("projectsupdate","display"):array() will always return (for this particular field) the "false" result, i.e., array(). But that array is completely empty!
Since the array is empty, the test array_search("1",array()) will always fail, and so 'checked="checked"' will never get written. And this is in fact the case - that radio group is not populated when the update page loads.
My conclusion is that an empty array at that point is an error. I don't know whether it's my error (although I haven't hacked this part of the code at all) or DB's error.
Sorry this is so long-winded, but it will sure help me understand the code to get your thoughts....