开发者

Zend_Form action and method

Zend_Form action and method shows by default <form action="" method="post">

... My wish is not like that...开发者_运维问答 Just be written <form> .. Is that possible ??

How can I do ???


well you can simply do the following but there really is no reason to to this! why would you want en empty form tag?

add this to your config to let the framework "know" your new helper

resources.view.helperPath.My_View_Helper = "My/View/Helper"

then in the file library/My/View/Helper.php create the class

class My_View_Helper_Form extends Zend_View_Helper_Form
{
    /**
     * Render HTML form without any attributes on the form-tag
     *
     * @param  string $name Form name
     * @param  null|array $attribs HTML form attributes
     * @param  false|string $content Form content
     * @return string
     */
    public function form($name, $attribs = null, $content = false)
    {
        $info = $this->_getInfo($name, $content, $attribs);
        extract($info);

        if (!empty($id)) {
            $id = ' id="' . $this->view->escape($id) . '"';
        } else {
            $id = '';
        }

        if (array_key_exists('id', $attribs) && empty($attribs['id'])) {
            unset($attribs['id']);
        }

        $xhtml = '<form>';

        if (false !== $content) {
            $xhtml .= $content
                   .  '</form>';
        }

        return $xhtml;
    }
}

it will automatically be used when you have configured your view resource properly

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜