I have added two additional fields to the function below which work fine ( name and number field ), however I would like to add an additional field before the submit button, but wherever I add it I get an error.
Can you tell me what is wrong with the code I have added:
<input type="text" placeholder="'.__('Questions or comments: (required)','dt_themes').'" name="quescomms" required>';
To this function and how do I correctly add it, and also add an " add to subscribers list? Tick " before the submit button?
Here is the code I have ( see the input section which is giving me the error ) :
function dt_sc_subscription_form( $atts, $content = null ) {
extract(shortcode_atts(array(
'image_url' => '',
'slider' => '',
'slider_id' => '',
'title' => __('Plan a Visit', 'dt_themse'),
'submit_text' => __('Submit', 'dt_themes'),
'success_msg' => __('Thanks for subscribing, we will contact you soon.', 'dt_themes'),
'error_msg' => __('Mail not sent, please try again Later.', 'dt_themes'),
'subject' => __('Subscription', 'dt_themes'),
'admin_email' => get_bloginfo('admin_email'),
'enable_planavisit' => 'true',
'contact_label' => __('Inquiries', 'dt_themes'),
'contact_number' => ''
), $atts));
if($admin_email == '') $admin_email = get_bloginfo('admin_email');
$out = '';
$out .= '<div class="column dt-sc-two-third no-space">
<div class="dt-sc-subscription-frm-image">';
if($image_url != '') {
$out .= '<img src="'.$image_url.'" alt="'.$title.'" title="'.$title.'">';
} else if($slider != '' && $slider_id != '') {
if($slider == 'LayerSlider') {
$out .= do_shortcode("[layerslider id='{$slider_id}']");
} elseif($slider == 'RevolutionSlider') {
$out .= do_shortcode("[rev_slider $slider_id]");
}
}
$out .= '</div>
</div>
<div class="column dt-sc-one-third no-space">
<div class="dt-sc-subscription-frm-container">
<h2> <i class="fa fa-clock-o"> </i> '.$title.' </h2>
<div class="dt-sc-clear"></div>
<form name="frmsubscription" action="'.get_template_directory_uri().'/framework/subscribe_mail.php" class="dt-sc-subscription-frm" method="post">
<input type="text" placeholder="'.__('Full Name (required)', 'dt_themes').'" name="dtfullname" required>
<input type="email" placeholder="'.__('Email (required)', 'dt_themes').'" name="dtemail" required>
<input type="text" placeholder="'.__('Tel No (required)', 'dt_themes').'" name="dttelno" required>';
$course_args = array('post_type' => 'dt_courses', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'DESC');
$course_array = get_posts( $course_args );
$out .= '<select id="dtcourse" name="dtcourse" required>';
$out .= '<option value="">' . __( 'Choose class, date, time, location? ', 'dt_themes' ) . '</option>';
<input type="text" placeholder="'.__('Questions or comments: (required)', 'dt_themes').'" name="quescomms" required>';
if ( count( $course_array ) > 0 ) {
foreach ($course_array as $course_item){
$out .= '<option value="' . esc_attr( $course_item->post_title ) . '" >' . esc_html( $course_item->post_title ) . '</option>';
}
}
$out .= '</select>';
if($enable_planavisit == 'true') {
$out .= '<div class="dt-sc-check-box">
<input type="checkbox" id="dtplanavisit" name="dtplanavisit"> <label class="checkbox-label"> <span> </span>'.__('Plan a Visit', 'dt_themes').' </label>
</div>
<input type="text" style="display: none;" id="dtdatetimepicker" name="dtdatetimepicker" placeholder="'.__('Date Time', 'dt_themes').'" >';
}
$out .= '<div id="ajax_subscribe_msg"></div>
<input type="submit" class="dt-sc-button" value="'.$submit_text.'" name="btnsubscribe" id="btnsubscribe">
<input type="hidden" value="'.$admin_email.'" name="hid_adminemail">
<input type="hidden" value="'.$subject.'" name="hid_subject">
<input type="hidden" value="'.$success_msg.'" name="hid_successmsg">
<input type="hidden" value="'.$error_msg.'" name="hid_errormsg">
</form>';
if($contact_number != '') {
$out .= '<div class="dt-sc-subscription-enquiry"> <i class="fa fa-phone"> </i> <span> '.$contact_label.' </span> '.$contact_number.' </div>';
}
$out .= '</div>
</div>';
You can't just write raw HTML into your PHP code. Maybe you meant to do something like this:
$out .= '<input type="text" placeholder="'.__('Questions or comments: (required)', 'dt_themes').'" name="quescomms" required>';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.