Xenology
Xenology

Reputation: 2452

Wordpress admin page stripping form tags

I have a php page that i've written within wordpress that is supposed to get some information from the database and display it to the page. I'm trying to add in the ability to update the information directly from the page and something seems to be stripping out my first form tag, but not the others. Has anyone ever seen anything like this or maybe know something that could potentially be happening?

Here is the PHP

function display_terms_by_brand()
{
global $wpdb;
$sql = "SELECT * FROM ".NINJA_FORMS_TERMS_TEXT;
$terms = $wpdb->get_results($sql, ARRAY_A);
?>

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('.edit').click(function(){
            jQuery(this).parent().find('.edit').css('display' , 'none')
            jQuery(this).parent().find('.save').css('display' , 'block')
            jQuery(this).parent().siblings('span[id*=brand_text_]').children('span').toggle();
            jQuery(this).parent().siblings('span[id*=brand_text_]').children('textarea').toggle();
        }); 
    })
</script>

<div id="termsHeader" style="font-weight:bold; font-size:16px; padding:10px 0; height:30px; min-width:600px;">
    <span style="width:10%; text-align:center; float:left; padding:0 30px;">Brand</span>
    <span style="width:67%; text-align:center; float:left;">Text</span>
    <span style="width:9%; text-align:center; float:right; padding:0 15px;">Edit / Save</span>
</div>

<div style="clear:both;"><!-- --></div>
<hr />

<?php
foreach($terms as $curr_term) {
?>

    <div style="width:100%; padding:20px 0; min-width:600px;" class="term">
        <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_<?php echo $curr_term['text_id'] ?>">
            <?php echo $curr_term['brand_name'] ?>
        </span>
        <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_<?php echo $curr_term['text_id'] ?>">
            <span> <?php echo stripslashes($curr_term['brand_text']) ?> </span>
            <textarea style="display:none; width:100%;"><?php echo stripslashes($curr_term['brand_text']) ?></textarea>
        </span>
        <span style="width:12%; height:50px; padding:30px 10px; float:right;">
            <form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_<?php echo $curr_term['text_id'] ?>" id="edit_<?php echo $curr_term['text_id'] ?>">
                <input name="brand_name" type="hidden" value="<?php echo $curr_term['brand_name'] ?>" />
                <textarea name="brand_text" style="display:none;">TEST</textarea>
                <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement" />  
                <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement" />  
                <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement" />  
            </form>
        </span>
    </div>

    <div style="clear:both;"><!-- --></div>
<?php
}
?>


<hr />
<h2>Add New Terms text</h2>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?page=ninja-forms-extend" method="post" name="add_new_term_text" id="add_new_term_text">
    <label style="float:left;width:50px;clear:left;font-weight:bold">Brand</label><input name="brand_name" type="text" size="38" />&nbsp;&nbsp;(This will be the shortcode to display the text)<br />
    <label style="float:left;width:50px;clear:left;font-weight:bold">Text</label><textarea name="brand_text" cols="35" rows="5"></textarea><br />
    <input name="submit" type="submit" value="Add New Terms Text" />
</form>
<?php
return;
}

and the resulting html for the first pass through the loop is this:

<div style="width:100%; padding:20px 0; min-width:600px;" class="term">
        <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_1">
            caprizehouse            </span>
        <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_1">
            <span> I certify that I am a resident of Canada over the age of 18, I agree to the <a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank">Privacy Policy</a> and <a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target="_blank">Terms and Conditions</a>, and I would like to receive the Canadian Prize House newsletter. </span>
            <textarea style="display:none; width:100%;">I certify that I am a resident of Canada over the age of 18, I agree to the &lt;a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank"&gt;Privacy Policy&lt;/a&gt; and &lt;a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target = "_blank"&gt;Terms and Conditions&lt;/a&gt;, and I would like to receive the Canadian Prize House newsletter.</textarea>
        </span>
        <span style="width:12%; height:50px; padding:30px 10px; float:right;">

                <input name="brand_name" type="hidden" value="caprizehouse">
                <textarea name="brand_text" style="display:none;">TEST</textarea>
                <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement">  
                <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement">  
                <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement">  

        </span>
    </div>

Notice how the form tag is missing. From the other two passes through the loop this is the HTML output to the page:

<div style="width:100%; padding:20px 0; min-width:600px;" class="term">
        <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_2">
            canadianprizes          </span>
        <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_2">
            <span> I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the  <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"> Terms and Conditions</a>, <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx">Privacy Policy</a> and <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx">Competition Rules</a>. I consent to my personal details being provided to  selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy. </span>
            <textarea style="display:none; width:100%;">I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the  &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"&gt; Terms and Conditions&lt;/a&gt;, &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx"&gt;Privacy Policy&lt;/a&gt; and &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx"&gt;Competition Rules&lt;/a&gt;. I consent to my personal details being provided to  selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy.</textarea>
        </span>
        <span style="width:12%; height:50px; padding:30px 10px; float:right;">
            <form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_2" id="edit_2">
                <input name="brand_name" type="hidden" value="canadianprizes">
                <textarea name="brand_text" style="display:none;">TEST</textarea>
                <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement">  
                <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement">  
                <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement">  
            </form>
        </span>
    </div>

There you will notice the form tag applied properly.

Upvotes: 0

Views: 993

Answers (1)

WayneT
WayneT

Reputation: 166

I had the same problem. Turned out I'd totally overlooked the fact that i was pulling in the form within the main options form.

Upvotes: 1

Related Questions