is built by htmlSelect(), whose first argument is the field name. // Reading only the literal attributes would miss those and the test would // claim a field is not submitted when it is. function keys_offered($source) { preg_match_all('/name="newJob\[([A-Za-z]+)\]"/', $source, $m); preg_match_all("/htmlSelect\\('newJob\\[([A-Za-z]+)\\]'/", $source, $m2); $keys = array_unique(array_merge($m[1], $m2[1])); sort($keys); return $keys; } // Likewise for an id: htmlSelect() takes it in its behaviours array. function has_id($source, $id) { return (bool)(preg_match('/id="'.$id.'"/', $source) or preg_match("/'id'\\s*=>\\s*'".$id."'/", $source)); } echo "the modal sends every field the action reads\n"; $read = keys_read($action); $offered = keys_offered($modal); check('the action reads some fields', count($read) > 0, true); check('the modal offers some fields', count($offered) > 0, true); check('and the two sets are the same', $offered, $read); echo "the modal is a complete, self-submitting form\n"; // A form built over ajax is outside the page's own