Magento – Default form action isn’t working in magento

magento-1.8php-5.4phpstorm

I am new to magento, I created the button in magento\app\design\frontend\base\default\template\catalog\product\list.phtml for sending emails for quote information. It's showing the button and When customer click on quote button I redirected my custom action
that is getUrl('wishlist/quote/index')

<form id="wishlist-view-form" action="<?php echo $this->getUrl('*/*/update', array('wishlist_id' => $this->getWishlistInstance()->getId())) ?>" method="post">
            ....
                <div>
                    <button class="form-button" type="submit" onclick="setLocation('<?php echo Mage::getUrl('wishlist/quote/index'); ?>')"><span>Submit</span></button>
                </div>

            </fieldset>
        </form>

but it's not working. By default, this form is firing $this->getUrl('*/*/update', array('wishlist_id' => $this->getWishlistInstance()->getId())) form action.

and I created controller in Magento\app\code\core\Mage\Wishlist\controllers\QuoteController.php

<?php

class Mage_Wishlist_QuoteController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
        Mage::log("customer");

        ....

        $this->_redirect('wishlist/index/index');
    }

}

and Magento\app\design\frontend\base\default\layout\wishlist.xml

<wishlist_quote_index>
        <reference name="content">
            <block name="customer.mail" type="wishlist/mail_email" template="wishlist/test.phtml"></block>
        </reference>
    </wishlist_quote_index>

why magento act like this? If I redirect using custom button how can I redirect/send/do some action?

thanks.

Best Answer

It is because when you press button it submits the form and is not setting location. Just set form action wishlist/quote/index. If button purpose is to submit form use action. If purpose is just redirect to some page use a link button.

Update:

For setting different submit url's for different buttons use:

onclick="editForm.submit('<?php echo Mage::getUrl('wishlist/quote/index'); ?>');return false;"

editForm - here is object which is creating to validate form. It should be defined in somewhere in magento\app\design\frontend\base\default\template\catalog\product\list.phtml. If not define it

var editForm = new varienForm('wishlist-view-form');