ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Action method doesn't work...

January 16, 2008 11:59am

Subscribe [2]
  • #1 / Jan 16, 2008 11:59am

    mschoening

    71 posts

    Hi,
    I have a normal form markup inside a template. Now I have defined an action for this form. The action is inside another template in the same template group and I used the path tag to reffer to it. It is not working. My question is because it’s not supposed to or because there is a bug somewhere…

    P.S: I did set the template with the action up to allow PHP!

    Thanks,
    Max

  • #2 / Jan 16, 2008 12:49pm

    Kyle Slattery

    109 posts

    It would probably help others to answer your question if you included the code you’re using.

  • #3 / Jan 16, 2008 1:36pm

    mschoening

    71 posts

    Well for a start it would help me to know if it is actually allowed to use the template path and a php code defined in a template as an action!

    Example:

    <code><form action="{path="group/template"}" method="get" ...</code>

    If it is it must be the code so I will post it.

    Thanks,
    Max

  • #4 / Jan 16, 2008 3:15pm

    Kyle Slattery

    109 posts

    Yeah, there’s no reason why that shouldn’t work.  What’s the HTML outputted by that tag?

  • #5 / Jan 17, 2008 1:24pm

    mschoening

    71 posts

    Hi,
    since I still haven’t figured out how to make it work I’m going to post a more extensive description of what I’m doing.

    I have a form in a normal template that looks like this:

    <form id="myform" action="{path="signup/_processor"}" method="post" accept-charset="{charset}">
        
            Name:
    
            <input id="name" name="name" type="text" value="" />
        
        
        
            <input name="submit" type="image" src="#" alt="Submit" />
        
    </form>

    and I have a small javascript (and the mootools.net library) to validate the field via AJAX:

    //<![CDATA[
            window.addEvent('domready', function() {
                $('myform').addEvent('submit', function(e) {
                    new Event(e).stop();
                    var log = $('log').empty().addClass('ajax-loading');
                    this.send( {
                        update: log,
                        onComplete: function() {
                            log.removeClass('ajax-loading');
                        }
                    });
                });
            });
        //]]>

    and my _processor template looks like this (not the full template beacuse I know the script works fine):

    <?php
        include('{path="signup/_functions"}');
        
        //Check user language.
        $language = $_POST['language'];
    
        // Check if name is available.
        if ($_POST['name'] == '') {
            if ($language == 'en') {
                $errors[] = "Name is required.";
            }
            else {
                $errors[] = "ES:Name is required.";
            }
        }

    Now the funny thing is if I remove the “_” (my indicator for hidden templates) from my _processor template and I comment out the javascript in my header (the one to call up the AJAX validation) it works just fine. A new page opens with just the errors. As soon as I put in the AJAX again it doesn´t work. Why can this be?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases