summaryrefslogtreecommitdiff
path: root/modules/profile.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-03-27 14:50:56 +0000
committerDries Buytaert <dries@buytaert.net>2004-03-27 14:50:56 +0000
commit5f17ad3c2df10663638683917ee92e366f79140c (patch)
tree0e4a455dcf0a9afed450ff0638e0641c32a6dac9 /modules/profile.module
parent3fbfc5203041b822b7bced5618fd310ba784cf5e (diff)
downloadbrdo-5f17ad3c2df10663638683917ee92e366f79140c.tar.gz
brdo-5f17ad3c2df10663638683917ee92e366f79140c.tar.bz2
- Profile module improvement:
* Made it possible to set certain fields as 'required'. To do: * Mark them as required visually. * Add required fields to the subscription page.
Diffstat (limited to 'modules/profile.module')
-rw-r--r--modules/profile.module8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/profile.module b/modules/profile.module
index d382687dc..e3db77656 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -185,6 +185,9 @@ function profile_validate_profile($edit) {
return t("The value provided for '%field' is not a valid URL.", array('%field' => $field->title));
}
}
+ else if ($field->required) {
+ return t("The field '%field' is required.", array('%field' => $field->title));
+ }
}
return $edit;
@@ -240,7 +243,7 @@ function profile_admin_add($type) {
drupal_set_message($error, 'error');
}
else {
- db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, overview, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s')", $data['title'], $data['name'], $data['explanation'], $data['category'], $type, $data['weight'], $data['overview'], $data['options'], $data['page']);
+ db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, overview, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s')", $data['title'], $data['name'], $data['explanation'], $data['category'], $type, $data['weight'], $data['required'], $data['overview'], $data['options'], $data['page']);
drupal_set_message(t('the field has been created.'));
}
@@ -262,7 +265,7 @@ function profile_admin_edit($fid) {
}
else {
- db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, overview = %d, options = '%s', page = '%s' WHERE fid = %d", $data['title'], $data['name'], $data['explanation'], $data['category'], $data['weight'], $data['overview'], $data['options'], $data['page'], $fid);
+ db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, required = %d, overview = %d, options = '%s', page = '%s' WHERE fid = %d", $data['title'], $data['name'], $data['explanation'], $data['category'], $data['weight'], $data['required'], $data['overview'], $data['options'], $data['page'], $fid);
drupal_set_message(t('the field has been updated.'));
}
@@ -291,6 +294,7 @@ Unless you know what you are doing, it is highly recommended that you prefix the
$group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
}
$group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
+ $group .= form_checkbox(t('Required field.'), 'required', 1, $edit['required']);
$output = form_group(t('Field settings'), $group);
$group = '';