* Create view wizard (Bryan Encina)
* Allow specification of MATCH, DEFERRABLE and INITIALLY DEFERRED on
foreign keys.
+* Automatically uncheck the NULL checkbox when data is typed in the value
+ field while editing data.
Bugs
* Fix pg_dump output for PostgreSQL 7.0.x and 7.1.x
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.198 2004/05/09 06:21:27 chriskl Exp $
+ * $Id: Postgres.php,v 1.199 2004/05/09 06:56:48 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @param $name The name to give the field
* @param $value The value of the field. Note this could be 'numeric(7,2)' sort of thing...
* @param $type The database type of the field
+ * @param $actions An array of javascript action name to the code to execute on that action
*/
- function printField($name, $value, $type) {
+ function printField($name, $value, $type, $actions = array()) {
global $lang;
+
+ // Determine actions string
+ $action_str = '';
+ foreach ($actions as $k => $v) {
+ $action_str .= " {$k}=\"" . htmlspecialchars($v) . "\"";
+ }
+
switch ($type) {
case 'bool':
case 'boolean':
// If value is null, 't' or 'f'...
if ($value === null || $value == 't' || $value == 'f') {
- echo "<select name=\"", htmlspecialchars($name), "\">\n";
+ echo "<select name=\"", htmlspecialchars($name), "\"{$action_str}>\n";
echo "<option value=\"\"", ($value === null) ? ' selected="selected"' : '', "></option>\n";
echo "<option value=\"t\"", ($value == 't') ? ' selected="selected"' : '', ">{$lang['strtrue']}</option>\n";
echo "<option value=\"f\"", ($value == 'f') ? ' selected="selected"' : '', ">{$lang['strfalse']}</option>\n";
echo "</select>\n";
}
else {
- echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\" />\n";
+ echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\"{$action_str} />\n";
}
break;
case 'text':
// addCSlashes converts all weird ASCII characters to octal representation,
// EXCEPT the 'special' ones like \r \n \t, etc.
if ($type == 'bytea') $value = addCSlashes($value, "\0..\37\177..\377");
- echo "<textarea name=\"", htmlspecialchars($name), "\" rows=\"5\" cols=\"28\" wrap=\"virtual\">\n";
+ echo "<textarea name=\"", htmlspecialchars($name), "\" rows=\"5\" cols=\"28\" wrap=\"virtual\"{$action_str}>\n";
echo htmlspecialchars($value);
echo "</textarea>\n";
break;
default:
-// echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\" onBlur=\"isEmpty(this);\" />\n";
- echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\" />\n";
+ echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\"{$action_str} />\n";
break;
}
}
* @param $return_desc The return link name
* @param $page The current page
*
- * $Id: display.php,v 1.36 2004/02/23 07:23:15 chriskl Exp $
+ * $Id: display.php,v 1.37 2004/05/09 06:56:48 chriskl Exp $
*/
// Include application functions
$attrs = &$data->getTableAttributes($_REQUEST['table']);
$rs = &$data->browseRow($_REQUEST['table'], $key);
- echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+ echo "<form action=\"$PHP_SELF\" method=\"post\" name=\"frmedit\">\n";
+ $elements = 0;
$error = true;
if ($rs->recordCount() == 1 && $attrs->recordCount() > 0) {
echo "<table>\n<tr>";
echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod']));
echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->f['attname']), "]\" value=\"",
htmlspecialchars($attrs->f['type']), "\" /></td>";
+ $elements++;
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
echo "<select name=\"format[", htmlspecialchars($attrs->f['attname']), "]\">\n";
echo "<option value=\"VALUE\"", ($_REQUEST['format'][$attrs->f['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$lang['strvalue']}</option>\n";
echo "<option value=\"EXPRESSION\"", ($_REQUEST['format'][$attrs->f['attname']] == 'EXPRESSION') ? ' selected="selected"' : '', ">{$lang['strexpression']}</option>\n";
echo "</select>\n</td>\n";
+ $elements++;
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">";
// Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS)
if (!$attrs->f['attnotnull']) {
$_REQUEST['nulls'][$attrs->f['attname']] = 'on';
}
echo "<input type=\"checkbox\" name=\"nulls[{$attrs->f['attname']}]\"",
- isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>";
+ isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>\n";
+ $elements++;
}
else
echo " </td>";
- echo "<td class=\"data{$id}\" nowrap>", $data->printField("values[{$attrs->f['attname']}]",
- $rs->f[$attrs->f['attname']], $attrs->f['type']), "</td>";
+ echo "<td class=\"data{$id}\" nowrap>";
+ // If the column allows nulls, then we put a JavaScript action on the data field to unset the
+ // NULL checkbox as soon as anything is entered in the field. We use the $elements variable to
+ // keep track of which element offset we're up to. We can't refer to the null checkbox by name
+ // as it contains '[' and ']' characters.
+ if (!$attrs->f['attnotnull'])
+ echo $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type'],
+ array('onChange' => 'elements[' . ($elements - 1) . '].checked = false;'));
+ else
+ echo $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type']);
+ echo "</td>";
+ $elements++;
echo "</tr>\n";
$i++;
$attrs->moveNext();