don't force the user to select a family if there's only one family... so we can basically ignore families

This commit is contained in:
Ryan Walberg 2012-12-06 03:03:22 +00:00
parent 092e0c65b9
commit 221b4c2df8
3 changed files with 24 additions and 12 deletions

View file

@ -40,6 +40,9 @@ if (isset($_POST["action"])) {
$pwd = $_POST["pwd"];
$email = $_POST["email"];
$familyname = $_POST["familyname"];
if (trim($familyname) == "") {
$familyname = "Default family";
}
// 1. create the family.
$stmt = dbh($opt)->prepare("INSERT INTO {$opt["table_prefix"]}families(familyname) VALUES(?)");
@ -188,7 +191,7 @@ else {
<form name="setupform" id="setupform" method="post" action="setup.php">
<input type="hidden" name="action" value="setup">
<div align="center">
<table cellpadding="3" class="partbox" width="50%">
<table cellpadding="3" class="partbox">
<tr>
<td colspan="2" class="partboxtitle" align="center">Set Up the Gift Registry</td>
</tr>
@ -229,7 +232,7 @@ else {
<input id="email" name="email" size="30" maxlength="255" type="text" value="<?php if (isset($_POST["email"])) echo htmlspecialchars($_POST["email"]); ?>" />
</td>
</tr>
<tr>
<tr valign="top">
<td>Default/initial family name</td>
<td>
<input id="familyname" name="familyname" size="50" maxlength="255" type="text" value="<?php if (isset($_POST["familyname"])) echo htmlspecialchars($_POST["familyname"]); ?>" />

View file

@ -95,11 +95,16 @@ while ($row = $stmt->fetch()) {
$families[] = $row;
}
if (count($families) == 1) {
// default the family to the single family we have.
$familyid = $families[0]["familyid"];
}
$smarty->assign('families', $families);
$smarty->assign('username', $username);
$smarty->assign('fullname', $fullname);
$smarty->assign('email', $email);
$smarty->assign('familyid', $familyid);
$smarty->assign('familycount', count($families));
$smarty->assign('action', $_POST["action"]);
if (isset($error)) {
$smarty->assign('error', $error);

View file

@ -128,6 +128,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<input id="email" name="email" type="text" class="input-xlarge" value="{$email|escape:'htmlall'}" placeholder="you@somewhere.com">
</div>
</div>
{if $familycount > 1}
<div class="control-group">
<label class="control-label" for="familyid">Family</label>
<div class="controls">
@ -139,6 +140,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</select>
</div>
</div>
{else}
<input type="hidden" name="familyid" value="{$familyid}">
{/if}
<div class="form-actions">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn" onClick="document.location.href='login.php';">Cancel</button>