[재질문] 필수 체크박스 생성 관련
본문
<?php
$date = esc_html( $_POST['date'] );
$title = isset($_POST['title']) ? esc_html( $_POST['title'] ) : '';
$timeslot = esc_html( $_POST['timeslot'] );
$timeslot_parts = explode('-',$timeslot);
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$user_array = booked_get_users();
$email_required = get_option('booked_require_guest_email_address',false);
$name_requirements = get_option('booked_registration_name_requirements',array('require_name'));
$name_requirements = ( isset($name_requirements[0]) ? $name_requirements[0] : false );
$calendar_id = (isset($_POST['calendar_id']) ? intval($_POST['calendar_id']) : false);
if ($calendar_id): $calendar_obj = get_term($calendar_id,'booked_custom_calendars'); $calendar_name = $calendar_obj->name; else: $calendar_name = ''; endif;
if ($timeslot_parts[0] == '0000' && $timeslot_parts[1] == '2400'):
$timeslotText = esc_html__('All day','booked');
else :
$timeslotText = date_i18n($time_format,strtotime($timeslot_parts[0])).' – '.date_i18n($time_format,strtotime($timeslot_parts[1]));
endif;
?>
<div class="booked-scrollable">
<p class="booked-title-bar"><small><?php esc_html_e('New Appointment','booked'); ?></small></p>
<?php if ($calendar_name): ?><p class="booked-calendar-name"><?php echo $calendar_name; ?></p><?php endif; ?>
<p class="name"><b><i class="booked-icon booked-icon-calendar"></i> <?php echo date_i18n($date_format, strtotime($date)); ?> <i class="booked-icon booked-icon-clock"></i> <?php echo $timeslotText; ?></b></p>
<form action="" method="post" class="booked-form" id="newAppointmentForm"<?php if ($calendar_id): echo ' data-calendar-id="'.$calendar_id.'"'; endif; ?>>
<input type="hidden" name="date" value="<?php echo date_i18n('Y-m-j', strtotime($date)); ?>" />
<input type="hidden" name="timestamp" value="<?php echo strtotime($date.' '.$timeslot_parts[0]); ?>" />
<input type="hidden" name="timeslot" value="<?php echo $timeslot; ?>" />
<?php $guest_booking = (get_option('booked_booking_type','registered') == 'guest' ? true : false); ?>
<div class="field">
<input data-condition="customer_type" type="radio" name="customer_type" id="customer_current" value="current" checked> <label for="customer_current"><?php esc_html_e('Current Customer','booked'); ?></label>
</div>
<div class="field">
<input data-condition="customer_type" type="radio" name="customer_type" id="customer_new" value="new"> <label for="customer_new"><?php esc_html_e('New Customer','booked'); ?></label>
</div>
<?php if ($guest_booking): ?>
<div class="field">
<input data-condition="customer_type" type="radio" name="customer_type" id="customer_guest" value="guest"> <label for="customer_guest"><?php esc_html_e('Guest','booked'); ?></label>
</div>
<?php endif; ?>
<br>
<div class="condition-block customer_type default" id="condition-current" data-condition-val="current">
<div class="field">
<select data-placeholder="<?php esc_html_e('Select a customer','booked'); ?>..." id="userList" name="user_id">
<option></option>
<?php foreach($user_array as $user): ?>
<option value="<?php echo $user->ID; ?>"><?php echo booked_get_name($user->ID); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="condition-block customer_type" id="condition-new" data-condition-val="new">
<?php if (isset($name_requirements) && $name_requirements == 'require_surname'): ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="name" />
<input value="" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="surname" />
</div>
<?php else: ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="name" />
</div>
<?php endif; ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('Email Address','booked'); ?>..." type="email" class="textfield" name="email" />
<input value="" placeholder="<?php esc_html_e('Choose a password','booked'); ?>..." type="password" class="textfield" name="password" />
</div>
</div>
<?php if ($guest_booking): ?>
<div class="condition-block customer_type" id="condition-guest" data-condition-val="guest">
<?php if (isset($name_requirements) && $name_requirements == 'require_surname'): ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="guest_name" />
<input value="" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="guest_surname" />
</div>
<?php else: ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="guest_name" />
</div>
<?php endif; ?>
<?php if ( $email_required ): ?>
<div class="field">
<input value="" placeholder="<?php esc_html_e('Email Address','booked'); ?>" type="email" class="large textfield" name="guest_email" />
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<hr>
<?php booked_custom_fields($calendar_id); ?>
<input type="hidden" name="booked_form_type" value="admin" />
<input type="hidden" name="action" value="booked_admin_add_appt" />
<input type="hidden" name="calendar_id" value="<?php echo $calendar_id; ?>" />
<input type="hidden" name="title" value="<?php echo esc_attr($title); ?>" />
<div class="field">
<input type="submit" class="button button-primary" value="<?php esc_html_e('Create Appointment','booked'); ?>">
<button class="cancel button"><?php esc_html_e('Cancel','booked'); ?></button>
</div>
</form>
</div>
<?php echo '<a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>';
오전에 어줍잖게 문의 드렸었는데 너무 광범위하게 여쭤봐서
제가 찾는 코드가 이것인것 같아 찾아서 다시 여쭙습니다.
현재 회원가입 시 이름 이메일 비밀번호 란이 필수란인데.
여기에 개인정보동의 라는 텍스트와 체크박스를 만들어서 필수로 하고 싶습니다.
어떻게 해야 하는지 고수님들의 답변을 듣고 싶습니다.
* 쌩초보라 코드를 아예 짤줄 모릅니다 ㅠㅠ..
!-->답변 2
<input type="checkbox" id="agree" name="agree" required> <label for="agree">개인정보이용동의</label>
required를 쓰면 html 자체적으로 필수입력항목으로 인식합니다
requried 가 정말 단순하니 좋습니다.
답변을 작성하시기 전에 로그인 해주세요.