[재질문] 필수 체크박스 생성 관련

[재질문] 필수 체크박스 생성 관련

QA

[재질문] 필수 체크박스 생성 관련

본문


<?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 자체적으로 필수입력항목으로 인식합니다


<div class="field">
	<label class="field-label"><?php esc_html_e("Registration:","booked"); ?><i class="required-asterisk booked-icon booked-icon-required"></i></label>
	<p class="field-small-p"><?php esc_html_e('Please enter your name, your email address and choose a password to get started.','booked'); ?></p>
</div>

<?php
	$name_requirements = get_option('booked_registration_name_requirements',array('require_name'));
	$name_requirements = ( isset($name_requirements[0]) ? $name_requirements[0] : false );
?>

<?php if ( $name_requirements == 'require_surname' ): ?>
	<div class="field">
		<input value="" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="booked_appt_name" />
		<input value="" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="booked_appt_surname" />
	</div>
<?php else: ?>
	<div class="field">
		<input value="" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="booked_appt_name" />
	</div>
<?php endif; ?>

<div class="field">
	<input value="" placeholder="<?php esc_html_e('Email Address','booked'); ?>..." type="email" class="textfield" name="booked_appt_email" />
	<input value="" placeholder="<?php esc_html_e('Choose a password','booked'); ?>..." type="password" class="textfield" name="booked_appt_password" />
</div>

<div class="field">
	<input value="" placeholder="<?php esc_html_e('info','booked'); ?>..." type="checkbox" class="textfield" name="booked_appt_info" />개인정보이용동의
	
</div>



이곳 레지스터라는 이름의 코드에서 맨 아랫줄에 임의로 체크박스를 생서해보니 생성은 되는데 아까 그 코드에서 네임값을 수정하라고 하시는것이 어떻게 맞춰야 하는걸까요 ㅠㅠ.? 넘 초보라 죄송합니다! 얼떨결에 간단한 작업이라고 해준다고 했다가 이런거 까지 시킬줄 몰랐어서.. 급한맘에 죄송합니다! 알려주심 넘 감사하겠습니다.

name값은 디비에 체크값을 저장할때 변경하시면됩니다
쿼리를 실행하는곳에서 해당 name값을 받아서 넣기때문에
받는곳에 맞춰서 바꿔주시면되는데
받는곳에서 그냥 agree로 받거나, DB에 저장안하시면 안바꿔도 상관없어요

답변을 작성하시기 전에 로그인 해주세요.
전체 756
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT