<div class="container-fluid">
    <div>
        <h3>Create New Custom Field</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Admin Panel</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Users</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Create New Custom Field</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Create New Custom Field</h6>
                    <div class="add-settings-alert"></div>
                    <div class="alert alert-info">Use {{ LANG lang_variable }} to translate the field data. e.g: {{ LANG first_name }}</div>
                    <form class="add-settings" method="POST">
                        <label for="type">Field Type</label>
                        <select class="form-control show-tick chosen-select" id="type" name="type">
                          <option value="textbox">Textbox</option>
               	          <option value="textarea">Textarea</option>
               	          <option value="select">Select box</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Field Name</label>
                                <input type="text" id="name" name="name" class="form-control">
                                
                            </div>
                        </div>
                       
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Field Length: <small>Default value is 32, and max value is 1000</small></label>
                                <input type="text" id="length" name="length" class="form-control" value="32">
                                
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Field Description: <small>The description will show under the field</small></label>
                                <textarea name="description" id="description" class="form-control" cols="30" rows="3"></textarea>
                                
                            </div>
                        </div>
                        <label for="placement">Field placement</label>
                        <select class="form-control show-tick " id="placement" name="placement">
                         <option value="general">General settings</option>
		                 <option value="profile">Profile settings</option>
		                 <option value="social">Social links</option>
		                 <option value="none">Don't show the field in settings page</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <label for="registration_page">Show On The Registration Page</label>
                        <select class="form-control show-tick" id="registration_page" name="registration_page">
                         		<option value="0" selected>No</option>
                 				<option value="1">Yes</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <label for="profile_page">Show On User Profile Page</label>
                        <select class="form-control show-tick" id="profile_page" name="profile_page">
                         		<option value="0" selected>No</option>
                 				<option value="1">Yes</option>
                        </select>
                        <div class="clearfix"></div>
                        <br><br>
                        <div class="form-group form-float options" style="display:none">
                            <div class="form-line">
                                <label class="form-label">Select Field Options: <small>One option per line.</small></label>
                                <textarea name="options" id="options" class="form-control" cols="30" rows="3"></textarea>
                                
                            </div>
                        </div>
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Create</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>
jQuery(document).ready(function($) {
    $('#type').on('change', function(evt, params) {
       var selectedValue = $(this).val();
       if (selectedValue == 'select') {
          $('.options').fadeIn(200);
       } 
       else {
          $('.options').fadeOut(200);
       }
       setTimeout(function () {
            $(".content").getNiceScroll().resize();
        }, 300);
    });

    var form_add_settings = $('form.add-settings');
    form_add_settings.ajaxForm({
        url: '{{LINK aj/ap/add-field}}',
        beforeSend: function() {
            form_add_settings.find('.waves-effect').text('Please wait..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.add-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Field added successfully</div>');
                setTimeout(function () {
                    window.location.href = "<?php echo PT_LoadAdminLinkSettings('manage-profile-fields'); ?>";
                }, 1000);
            }

            else if (data.status == 400) {
                $('.add-settings-alert').html('<div class="alert alert-danger">'+data.message+'</div>');
                setTimeout(function () {
                    $('.add-settings-alert').html('');
                }, 2000);
            }
            form_add_settings.find('.waves-effect').text('Create');
        }
    });
});
</script>