public function render_admin_form($message = '')
    {
        if (empty($this->id)) {
            $title = __('Add Field', 'buddypress');
            $action = "users.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id;
            if (!empty($_POST['saveField'])) {
                $this->name = $_POST['title'];
                $this->description = $_POST['description'];
                $this->is_required = $_POST['required'];
                $this->type = $_POST['fieldtype'];
                $this->order_by = $_POST["sort_order_{$this->type}"];
                $this->field_order = $_POST['field_order'];
            }
        } else {
            $title = __('Edit Field', 'buddypress');
            $action = "users.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id . "#tabs-" . $this->group_id;
        }
        ?>

		<div class="wrap">
			<div id="icon-users" class="icon32"><br /></div>
			<h2><?php 
        echo esc_html($title);
        ?>
</h2>

			<?php 
        if (!empty($message)) {
            ?>

				<div id="message" class="error fade">
					<p><?php 
            echo esc_html($message);
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<form id="bp-xprofile-add-field" action="<?php 
        echo esc_url($action);
        ?>
" method="post">
				<div id="poststuff">
					<div id="post-body" class="metabox-holder columns-<?php 
        echo 1 == get_current_screen()->get_columns() ? '1' : '2';
        ?>
">
						<div id="post-body-content">
							<div id="titlediv">
								<input type="text" name="title" id="title" value="<?php 
        echo esc_attr($this->name);
        ?>
" />
							</div>
							<div class="postbox">
								<h3><?php 
        _e('Field Description', 'buddypress');
        ?>
</h3>
								<div class="inside">
									<textarea name="description" id="description" rows="8" cols="60"><?php 
        echo esc_textarea($this->description);
        ?>
</textarea>
								</div>
							</div>
						</div><!-- #post-body-content -->

						<div id="postbox-container-1" class="postbox-container">
							<div id="submitdiv" class="postbox">
								<h3><?php 
        _e('Submit', 'buddypress');
        ?>
</h3>
								<div class="inside">
									<div id="submitcomment" class="submitbox">
										<div id="major-publishing-actions">
											<input type="hidden" name="field_order" id="field_order" value="<?php 
        echo esc_attr($this->field_order);
        ?>
" />
											<div id="publishing-action">
												<input type="submit" value="<?php 
        esc_attr_e('Save', 'buddypress');
        ?>
" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" />
											</div>
											<div id="delete-action">
												<a href="users.php?page=bp-profile-setup" class="deletion"><?php 
        _e('Cancel', 'buddypress');
        ?>
</a>
											</div>
											<?php 
        wp_nonce_field('xprofile_delete_option');
        ?>
											<div class="clear"></div>
										</div>
									</div>
								</div>
							</div>

							<?php 
        /* Field 1 is the fullname field, which cannot have custom visibility */
        ?>
							<?php 
        if (1 != $this->id) {
            ?>

								<div class="postbox">
									<h3><label for="default-visibility"><?php 
            _e('Default Visibility', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<ul>

											<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

												<li>
													<input type="radio" id="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]" name="default-visibility" value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                checked($this->default_visibility, $level['id']);
                ?>
 />
													<label for="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]"><?php 
                echo esc_html($level['label']);
                ?>
</label>
												</li>

											<?php 
            }
            ?>

										</ul>
									</div>
								</div>

								<div class="postbox">
									<h3><label for="allow-custom-visibility"><?php 
            _e('Per-Member Visibility', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<ul>
											<li>
												<input type="radio" id="allow-custom-visibility-allowed" name="allow-custom-visibility" value="allowed" <?php 
            checked($this->allow_custom_visibility, 'allowed');
            ?>
 />
												<label for="allow-custom-visibility-allowed"><?php 
            _e("Let members change this field's visibility", 'buddypress');
            ?>
</label>
											</li>
											<li>
												<input type="radio" id="allow-custom-visibility-disabled" name="allow-custom-visibility" value="disabled" <?php 
            checked($this->allow_custom_visibility, 'disabled');
            ?>
 />
												<label for="allow-custom-visibility-disabled"><?php 
            _e('Enforce the default visibility for all members', 'buddypress');
            ?>
</label>
											</li>
										</ul>
									</div>
								</div>

							<?php 
        }
        ?>
						</div>

						<div id="postbox-container-2" class="postbox-container">

							<?php 
        /* Field 1 is the fullname field, which cannot be altered */
        ?>
							<?php 
        if (1 != $this->id) {
            ?>

								<div class="postbox">
									<h3><label for="required"><?php 
            _e("Field Requirement", 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<select name="required" id="required" style="width: 30%">
											<option value="0"<?php 
            selected($this->is_required, '0');
            ?>
><?php 
            _e('Not Required', 'buddypress');
            ?>
</option>
											<option value="1"<?php 
            selected($this->is_required, '1');
            ?>
><?php 
            _e('Required', 'buddypress');
            ?>
</option>
										</select>
									</div>
								</div>

								<div class="postbox">
									<h3><label for="fieldtype"><?php 
            _e('Field Type', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">
											<?php 
            bp_xprofile_admin_form_field_types($this->type);
            ?>
										</select>

										<?php 
            // Deprecated filter, don't use. Go look at {@link BP_XProfile_Field_Type::admin_new_field_html()}.
            do_action('xprofile_field_additional_options', $this);
            $this->render_admin_form_children();
            ?>
									</div>
								</div>

							<?php 
        } else {
            ?>

								<input type="hidden" name="required"  id="required"  value="1"       />
								<input type="hidden" name="fieldtype" id="fieldtype" value="textbox" />

							<?php 
        }
        ?>

						</div>
					</div><!-- #post-body -->

				</div><!-- #poststuff -->

			</form>
		</div>

<?php 
    }
    /**
     * Output the metabox for setting what type of field this is.
     *
     * @since 2.3.0
     *
     * @return void If default field.
     */
    private function type_metabox()
    {
        // Default field cannot change type.
        if (true === $this->is_default_field()) {
            return;
        }
        ?>

		<div class="postbox">
			<h2><label for="fieldtype"><?php 
        esc_html_e('Type', 'buddypress');
        ?>
</label></h2>
			<div class="inside">
				<select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">

					<?php 
        bp_xprofile_admin_form_field_types($this->type);
        ?>

				</select>

				<?php 
        // Deprecated filter, don't use. Go look at {@link BP_XProfile_Field_Type::admin_new_field_html()}.
        do_action('xprofile_field_additional_options', $this);
        $this->render_admin_form_children();
        ?>

			</div>
		</div>

	<?php 
    }