2
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">

and

<form action="<?php echo $this->getUrl('customer/account/createpost'); ?>" method="post" id="form-validate">

both code call AccountController and createPostAction action but the first one make this process very complicated.so my qustion is why magento use this complicated method .

here action call this Function

public function getPostActionUrl()
{
    return $this->helper('customer')->getRegisterPostUrl();
}

and then Block use helper

public function getRegisterPostUrl()
{
    return $this->_getUrl('customer/account/createpost');
}
3

The answer is simple. Extensibility & Enapsulation.
Having the URL returned by a method, you can call that method everywhere in the code without the need to remember what the actual URL is.
Also in case the core team decides to change the url, they will do it in a single place.

If YOU decide to change the url all you need to do is to rewrite one single method.

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.