2

Similar to the question asked here: How to add a tags-field to an entry form?

I am trying to create an entry form that can create tags. I'm using http://selectize.github.io/selectize.js/ for the select element.

I am currently able to submit the form with existing tags but when trying to create a new tag using

$.post('/tags/createTag', data, function(response) {
    if (response.success) {
        alert('Success')
    } else {
        alert('Unable to create that tag.');
    }
});

I get http://talkbox.es:8888/index.php/tags/createTag 404 (Not Found)

Let me know if you guys need any more information, I'll gladly get it for you! Thanks a ton in advance.

| improve this question | | | | |
2

It looks like you are not targeting the action URL. When accessing a Craft controller, you'll need to use the actionTrigger in your URL:

Your current URL:

http://talkbox.es:8888/index.php/tags/createTag

Should be updated to:

http://talkbox.es:8888/index.php/actions/tags/createTag

The actionTrigger is configurable so if you plan to reuse your code on multiple sites, you won't want to hard code that value. In twig, you can output that value using the craft.config variable:

{{ craft.config.actionTrigger }}
| improve this answer | | | | |
  • I had tried with /actions/ in the url before but i still get index.php/actions/tags/createTag 400 (Bad Request) is there something i'm missing in my config file? – Maxim Siebert Apr 29 '16 at 14:02
  • @MaximSiebert what was the cause of the Bad Request error? I am experiencing the same in a Craft 3 project – Mark Jun 6 '18 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.