<div class="container-fluid">
    <div class="block-header">
        <h2>Users > Create New Custom Field</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="header">
                    <h2>Create New Custom Field</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success add-settings-alert"></div>
                    <span class="help-block">Use {{ LANG lang_variable }} to translate the field data. e.g: {{ LANG first_name }}</span><br>
                    <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">
                                <input type="text" id="name" name="name" class="form-control">
                                <label class="form-label">Field Name</label>
                            </div>
                        </div>
                       
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="length" name="length" class="form-control" value="32">
                                <label class="form-label">Field Length: <small>Default value is 32, and max value is 1000</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="description" id="description" class="form-control" cols="30" rows="3"></textarea>
                                <label class="form-label">Field Description: <small>The description will show under the field</small></label>
                            </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">
                                <textarea name="options" id="options" class="form-control" cols="30" rows="3"></textarea>
                                <label class="form-label">Select Field Options: <small>One option per line.</small></label>
                            </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);
       }
    });

    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('<i class="fa fa-check"></i> Field added successfully');
                setTimeout(function () {
                    window.location.href = "<?php echo PT_LoadAdminLinkSettings('manage-profile-fields'); ?>";
                }, 1000);
            }

            else if (data.status == 400) {
              alert(data.message);
            }
            form_add_settings.find('.waves-effect').text('Create');
        }
    });
});
</script>