테스트 사이트 - 개발 중인 베타 버전입니다

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

wonderGAS 5년 전 조회 4,714

</p>

<p><?php</p>

<p>$date = esc_html( $_POST['date'] );

$title = isset($_POST['title']) ? esc_html( $_POST['title'] ) : '';

$timeslot = esc_html( $_POST['timeslot'] );

$timeslot_parts = explode('-',$timeslot);</p>

<p>$date_format = get_option('date_format');

$time_format = get_option('time_format');</p>

<p>$user_array = booked_get_users();</p>

<p>$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 );</p>

<p>$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;</p>

<p>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;</p>

<p>?>

<div class="booked-scrollable"></p>

<p>    <p class="booked-title-bar"><small><?php esc_html_e('New Appointment','booked'); ?></small></p></p>

<p>    <?php if ($calendar_name): ?><p class="booked-calendar-name"><?php echo $calendar_name; ?></p><?php endif; ?></p>

<p>    <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; ?>></p>

<p>        <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; ?>" /></p>

<p>        <?php $guest_booking = (get_option('booked_booking_type','registered') == 'guest' ? true : false); ?></p>

<p>        <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></p>

<p>        <?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; ?></p>

<p>        
</p>

<p>        <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></p>

<p>        <div class="condition-block customer_type" id="condition-new" data-condition-val="new"></p>

<p>            <?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; ?></p>

<p>            <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></p>

<p>        <?php if ($guest_booking): ?></p>

<p>            <div class="condition-block customer_type" id="condition-guest" data-condition-val="guest"></p>

<p>                <?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; ?></p>

<p>                <?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; ?></p>

<p>            </div></p>

<p>        <?php endif; ?></p>

<p>        <hr></p>

<p>        <?php booked_custom_fields($calendar_id); ?></p>

<p>        <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); ?>" /></p>

<p>        <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></p>

<p>    </form>

</div></p>

<p><?php echo '<a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>';

 

오전에 어줍잖게 문의 드렸었는데 너무 광범위하게 여쭤봐서

제가 찾는 코드가 이것인것 같아 찾아서 다시 여쭙습니다.

 

현재 회원가입 시 이름 이메일 비밀번호 란이 필수란인데.

여기에 개인정보동의 라는 텍스트와 체크박스를 만들어서 필수로 하고 싶습니다.

어떻게 해야 하는지 고수님들의 답변을 듣고 싶습니다.

 

* 쌩초보라 코드를 아예 짤줄 모릅니다 ㅠㅠ..

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

5년 전

requried 가 정말 단순하니 좋습니다. 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

 

required를 쓰면 html 자체적으로 필수입력항목으로 인식합니다

로그인 후 평가할 수 있습니다

답변에 대한 댓글 7개

w
wonderGAS
5년 전
위 코드를 아무곳에나 넣어도 되나요?
병원에서일해요
5년 전
네 원하시는 위치에 넣으시고

스타일, name값 수정해주셔야됩니다

별도로 db에 체크값 저장하시는거 아니면 스타일만 입혀서 사용하시면 됩니다
w
wonderGAS
5년 전
[code]
<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>

[/code]

이곳 레지스터라는 이름의 코드에서 맨 아랫줄에 임의로 체크박스를 생서해보니 생성은 되는데 아까 그 코드에서 네임값을 수정하라고 하시는것이 어떻게 맞춰야 하는걸까요 ㅠㅠ.? 넘 초보라 죄송합니다! 얼떨결에 간단한 작업이라고 해준다고 했다가 이런거 까지 시킬줄 몰랐어서.. 급한맘에 죄송합니다! 알려주심 넘 감사하겠습니다.
병원에서일해요
5년 전
name값은 디비에 체크값을 저장할때 변경하시면됩니다
쿼리를 실행하는곳에서 해당 name값을 받아서 넣기때문에
받는곳에 맞춰서 바꿔주시면되는데
받는곳에서 그냥 agree로 받거나, DB에 저장안하시면 안바꿔도 상관없어요
w
wonderGAS
5년 전
그렇다면 맨 아랫줄에 넣은 checkbox를 생성이 되었다면 자동으로 필수로 잡히는게 맞는건가요? 헌데 지금 해보니 체크 안해도 회원가입이 진행이 됩니다..
w
wonderGAS
5년 전
물론 처음에 알려주신 인풋 코드는 아까 거기에서 적당한 자리에 넣었습니다.
병원에서일해요
5년 전
체크박스에 required 넣어주셔야되요

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인