Переглянути джерело

If a field is required at registration should better be into the 'required informations' box

Signed-off-by: emanuele <[email protected]>
emanuele 12 роки тому
батько
коміт
24b31a82b8
2 змінених файлів з 27 додано та 2 видалено
  1. 4 1
      Sources/Profile.php
  2. 23 1
      Themes/default/Register.template.php

+ 4 - 1
Sources/Profile.php

@@ -686,7 +686,7 @@ function loadCustomFields($memID, $area = 'summary')
 	// Load all the relevant fields - and data.
 	$request = $smcFunc['db_query']('', '
 		SELECT
-			col_name, field_name, field_desc, field_type, field_length, field_options,
+			col_name, field_name, field_desc, field_type, show_reg, field_length, field_options,
 			default_value, bbc, enclose, placement
 		FROM {db_prefix}custom_fields
 		WHERE ' . $where,
@@ -695,6 +695,7 @@ function loadCustomFields($memID, $area = 'summary')
 		)
 	);
 	$context['custom_fields'] = array();
+	$context['custom_fields_required'] = false;
 	while ($row = $smcFunc['db_fetch_assoc']($request))
 	{
 		// Shortcut.
@@ -779,7 +780,9 @@ function loadCustomFields($memID, $area = 'summary')
 			'placement' => $row['placement'],
 			'colname' => $row['col_name'],
 			'value' => $value,
+			'show_reg' => $row['show_reg'],
 		);
+		$context['custom_fields_required'] = $context['custom_fields_required'] || $row['show_reg'];
 	}
 	$smcFunc['db_free_result']($request);
 }

+ 23 - 1
Themes/default/Register.template.php

@@ -171,7 +171,26 @@ function template_registration_form()
 							<input type="text" name="openid_identifier" id="openid_url" size="30" tabindex="', $context['tabindex']++, '" value="', isset($context['openid']) ? $context['openid'] : '', '" class="input_text openid_login" />
 						</dd>
 					</dl>';
+	}
+
+	// If there is any field marked as required, show it here!
+	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
+	{
+		echo '
+
+					<dl class="register_form">';
 
+		foreach ($context['custom_fields'] as $field)
+			if ($field['show_reg'] > 1)
+				echo '
+						<dt>
+							<strong', !empty($field['is_error']) ? ' style="color: red;"' : '', '>', $field['name'], ':</strong>
+							<span class="smalltext">', $field['desc'], '</span>
+						</dt>
+						<dd>', $field['input_html'], '</dd>';
+
+		echo '
+					</dl>';
 	}
 
 	echo '
@@ -277,12 +296,15 @@ function template_registration_form()
 	if (!empty($context['custom_fields']))
 	{
 		foreach ($context['custom_fields'] as $field)
-			echo '
+		{
+			if ($field['show_reg'] < 2)
+				echo '
 						<dt>
 							<strong', !empty($field['is_error']) ? ' style="color: red;"' : '', '>', $field['name'], ':</strong>
 							<span class="smalltext">', $field['desc'], '</span>
 						</dt>
 						<dd>', $field['input_html'], '</dd>';
+		}
 	}
 
 	// If we have either of these, close the list like a proper gent.