• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED Woody closes form element on its own and prematurely

snlsn

New member
Messages
3
Likes
0
Points
1
#1
I'm at my wits' end.
I'm opening a form element in a Woody PHP snippet and inserting some conditional logic (because PayPal "Buy Now" buttons don't support discount codes, but that's besides the point).
So I open the form element in the Woody snippet and include the conditional logic.
I insert the snippet into the page with a shortcode.
Handwritten HTML on the page itself continues with the rest of the form, including the closing tag for the form.
While trying to understand why the submit button did nothing, I discovered the closing tag for the form was in the Woody snippet.
Way sooner than it should appear, obviously. This essentially shuts down the form before any of the form inputs, including the submit input.
In other words, the snippet is opening AND closing the form element, but I only want it to OPEN the form.
I deleted the unwanted </form> tag and updated the snippet. The closing tag for the form immediately reappeared.
Again and again!
I copied and pasted the code I want into a new snippet, and the </form> tag again appeared and I can't for the life of me figure out how to prevent Woody from "helpfully" closing the form when I don't want it to.
Any thoughts or suggestions?
Thanks in advance.
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#2
Hello.

Woody doesn't add closing tags automatically. Perhaps it makes another plugin or extension for your browser?

Send the snippet code and a link to the site so I can see where it is posted.
 

snlsn

New member
Messages
3
Likes
0
Points
1
#3
Thank you, Artem.
The snippet I created does two things. First, it determines if a coupon code has been entered (via a very small form) and then stores one of two PayPal button code numbers in the hostedButtonId variable. That part is working fine in Woody.

Second, after the appropriate button code has been stored in the variable, a new form is created to collect additional information before sending the user to PayPal to complete the transaction. This second form is started in the Woody snippet, but closed the the page's HTML markup. The problematic part of the snippet is shown below. The problem is that the Woody snippet editor adds </form> (as shown in the code block below) when I save or update the snippet. That closing tag should not be there, I can't make it not be there, and it renders the submit button useless.

PHP:
echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'><input name='cmd' type='hidden' value='_s-xclick' />";
echo "<input name='hosted_button_id' type='hidden' value='$hostedButtonId' />";</form>
The URL to this page is: Subscribe to FirstTerm!

I solved the issue by including the entire form in the Woody snippet instead of just starting it in Woody, but that doesn't feel like the most elegant use of the plugin.

By the way, I always try to keep plugins up to date, but this morning as I was preparing to type this reply I noticed there is an update to the plugin. I have not updated it yet, but maybe the issue will be resolved by this update????
Thank you again.
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#4
The Woody plugin does not automatically close tags. Perhaps it makes another plugin.
If you give me access to the admin, I can see what could be the problem.

An elegant use of woody is to just place all the extra code in a snippet. For example, you can now use this form anywhere else on the site.

The changelog of new version of the plugin can be found in the Wordpress repository.
 

snlsn

New member
Messages
3
Likes
0
Points
1
#5
Thanks again. As long as I got it to work by putting the whole form in the snippet instead of just a portion, I guess I'll leave it at that.
Thanks again for your time, and for a useful plugin!
Steve