dongye9453 2015-06-22 21:08
浏览 28

如何向函数添加其他字段?

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>';
  • 写回答

1条回答 默认 最新

  • douken1726 2015-06-22 22:09
    关注

    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>';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计