+/**
+ * Constructs the "new address" form
+ *
+ * NOTE! The form is not closed - the caller
+ * must add the closing form tag itself.
+ *
+ * @since 1.5.1
+ *
+ * @param string $form_url Form action url
+ * @param string $name Form name
+ * @param string $title Form title
+ * @param string $button Form button name
+ * @param int $backend The current backend being displayed
+ * @param array $defdata Values of form fields
+ *
+ * @return string The desired address form display code
+ *
+ */
+function abook_create_form($form_url, $name, $title, $button,
+ $backend, $defdata=array()) {
+
+ global $oTemplate;
+
+ $output = addForm($form_url, 'post', 'f_add', '', '', array(), TRUE);
+
+ if ($button == _("Update address")) {
+ $edit = true;
+ $backends = NULL;
+ } else {
+ $edit = false;
+ $backends = getWritableBackends();
+ }
+
+ $fields = array (
+ 'nickname' => 'NickName',
+ 'firstname' => 'FirstName',
+ 'lastname' => 'LastName',
+ 'email' => 'Email',
+ 'label' => 'Info',
+ );
+ $values = array();
+ foreach ($fields as $sqm=>$template) {
+ $values[$template] = isset($defdata[$sqm]) ? $defdata[$sqm] : '';
+ }
+
+ $oTemplate->assign('writable_backends', $backends);
+ $oTemplate->assign('values', $values);
+ $oTemplate->assign('edit', $edit);
+ $oTemplate->assign('current_backend', $backend);
+
+ $output .= $oTemplate->fetch('addrbook_addedit.tpl');
+
+ return $output;
+}
+