What exactly is the difference between {$taxonomy}_add_form_fields and {$taxonomy}_add_form - wordpress

I'm observing very similar behavior for both {$taxonomy}_add_form_fields and {$taxonomy}_add_form is there a diference and what it is? I understand the semantic difference of form and form field, but I'm wondering how WP sees it.
There is no record of it in the Wordpress Codex and Developer part of the Wordpress website is giving almost same description.
See for yourself:
https://developer.wordpress.org/reference/hooks/taxonomy_add_form_fields/
https://developer.wordpress.org/reference/hooks/taxonomy_add_form/

Taking a look into /wp-admin/edit-tags.php, we can see the do_action( "{$taxonomy}_add_form", $taxonomy ); is used to replace to preceding deprecated filters. That's why it was added.
Getting to the "difference" between them, you could see in the code that the filter {$taxonomy}_add_form_fields is used to add data to the form just before the submit button has been created, while the other filter {$taxonomy}_add_form is used after the submit button (but still before the closing tag </form>.
Usually, you could think about putting visible fields before the submit button and then adding hidden fields right after it. But it's not a sort of great difference between them.

Both of actions is in the form tag.
But, {$taxonomy}_add_form_fields action is before submit button and "{$taxonomy}_add_form" action is after submit button and add_tag_form action.

Related

Changing the location of Woocommerce coupon code on checkout makes purchase button stop working?

Ok so I have looked everywhere for a solution to this but I can't figure out why this is happening. Logically it makes no sense. I'm not really a coder but I know some basic PHP.
I used the following code to simply move the coupon field in Woo checkout to a different location:
/*** MOVE THE COUPON CODE ***/
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_after_order_notes', 'woocommerce_checkout_coupon_form' );
After this code is added, the "Buy Now" checkout button to finalize the order does nothing on click, like the JS is disabled.
When the code is removed and coupon code goes back to original location, the button works normally.
Has anyone else had this happen to them? It's so bizarre.
You can see the page (with code above implemented) here:
http://insiders.nomadmoguls.com/payment/?add-to-cart=205479&variation_id=205481&attribute_pa_type-of-pass=yearly
Thanks in advance for everyone's help! This was my last resort after several hours looking for a solution on my own!
The issue is caused by the hook you're using, woocommerce_after_order_notes. It's causing the <form name="checkout"> to close before the Submit button, so the Sign Up Now button isn't actually inside that form anymore, so it can't submit it when it's clicked, since your (paraphrased) markup is like this:
<form name="checkout">
<!-- coupon code stuff -->
</form>
<button type="submit">Sign Up Now</button>
Check out this video of me on the site with Dev Tools open. You can see the Sign Up Now button outside the Checkout form - as soon as I drag it up to be inside the form, it works just fine.
A relatively common misconception is that "Coupon Code" is a checkout form field, when it's really it's own separate form, so of course - it doesn't want to be nested directly inside the checkout form (you can't have forms inside forms).
This means you have real two options, without doing something crazy like rebinding a click handler on the submit button to submit the form:
Use a hook that comes after the checkout form, such as woocommerce_after_checkout_form instead of woocommerce_after_order_notes.
Keep the coupon form at its original location.

Refresh button without prompt on symfony

I need make a button for refresh a page withe the same values POST in bafore form.
The flow work is: Form1(values) > show | show > refresh button (with the same values ion From1)
I try with javascript but allways get Prompt (resend data?). So, I make a other form(Form2) for the refresh with all fields hidden and i want put all values on Form1 in the Form2 fields.
Thanks !
Finally I found a solution... but is not simple.
Frist, we need the 2 forms, the form for introduce the data, and the form with the same fields but hidden.
So, we need pass the data from the first form in return of the action in controller, and then, in the view reassign this data to hidden fields from from 2.
I use Twig for this.
I hope that it's usefull for other persons whit the same problem.

Button State Persistence

I have a 'Create Post' button in which a user can use to submit a post. I only want the user to be able to create one post at a time. So the user would have to remove the first post to create another, or they would have to wait for that post to be removed by someone else - which is perfectly acceptable.
Also, I want the button to be disabled when there is already a live post of theirs.
So, basically, what's the best way to attach the state of the button to the state of the post, so that as soon as the post is removed, the button is then enabled.
Thanks.
Fortunately, spacebars makes this really easy to do. Have a look at the "Smarter Attributes" section of this post.
Here is an example:
<template name="post">
<button disabled={{isDisabled}}>Create Post</button>
</template>
Template.post.isDisabled = function () {
return Posts.findOne();
};
In this case the button will be disabled if any posts were found, but you can easily modify that to your specific requirements.

How to Get GA to do Site Search with Tumblr

In Tumblr, searches are set up so that the query is a method/parameter of the search controller. Basically it looks like this: /search/:query.
I've been playing around from the client side trying to edit it so that it posts in this format:
/search/example?q=example
I'm doing this because GA looks for a parameter in searches. My problem is is that from the JavaScript to the form methods and actions, I cannot get the thing to spit out a query parameter at the end.
Is there anyway to tell Google to look for /search/:query instead of looking for a parameter in the URI?
Yes, you can do this by creating an advanced filter.
Go to your account Admin and then either click on the Account > All filters button on the left, or else the View > Filters button the right. Which one you use depends on whether you want this to be applied to all properties/views of the account, or only to an individual view.
Then, click the + New Filter button.
Enter in a name for your Filter Name such as "search string"
For filter type, select Custom filter radio button.
Then select the Advanced radio button.
Then from the Field A->Extract A dropdown, select Request URI. In the input field to the right of this, enter in ^\/search\/(.*)
Then from the Output To->Construtor dropdown, select Search Term. In the input field to the right of this, enter in $A1
Then save the filter and you should be good to go.

Why can't I set a value on this form field in wordpress admin?

I'm trying to get the value of a form field on submit using jQuery. However when I try to alert it, it's shows up as undefined, with text in.
var title=jQuery('#fields[field_4f52672267672]').val();
alert(title);
It's got a funny ID though because I'm using a form plugin to create my form. When I inspect the element it simply shows the value attribute with no value beside it, even when it contains text. Can anyone explain what is going on please?
I've attached a screenshot of the field inspected with chrome's inspector panel.
var title=jQuery('#fields\\[field_4f52672267672\\]').val();
Into selectors you have to escape with 2 backslashes.

Resources