Need to Convert smarty file to zend? [duplicate]

2019-09-19 15:19发布

问题:

Possible Duplicate:
Need to change smarty file into zend file

Hi I have a one tpl file with the name of login.tpl in smarty..so now i need to create a form like login.php and ini file for this form in zend framework..

here is the example code..so need to convert to form and ini file for this in zend..

/* login.tpl file */

<div id="add-user-form" class="form">
    <form action="/account/login" method="post">
    {{input_text type="hidden" name="redirect_url" value=$smarty.server.REDIRECT_URL|default:"/"}}

    <div class="contain">
        <div class="fieldgrp">
            <label>&nbsp;</label>
            <div class="field"><p><h3>Enter&nbsp;User&nbsp;Credentials</h3></p></div>
        </div>

        <div class="fieldgrp">
            <label for="login_name">Username </label>
            <div class="field">{{input_text name="login" id="login_name" class="longfield" maxlength="100"}}</div>
        </div>

        <div class="fieldgrp">
            <label for="login_password">Password </label>
            <div class="field">{{input_text type="password" name="password" id="login_password" class="longfield" maxlength="100"}}</div>
        </div>

        <div class="fieldgrp">
            <label>&nbsp;</label>
            <div class="field"><input type="submit" value="Login" /></div>
        </div>
    </div>

    </form>
</div>

回答1:

You have a couple of options:

  1. create a Zend_Form element and assign decorators to get the output you want
  2. create a Zend_Form element and render it using the view script decorator to duplicate the layout of the form (easier then no. 1 but the level of reuse is low)
  3. create the form using plain old html (you loose automatic rendering of errors, and need to output the value of each element manually)
  4. use Smarty as your View in Zend Framework (it has the same cons as the option no.3)

Whichever path you choose you will have to get your hands dirty and learn something new. ZF documentation is a place to start. But be warned, Zend_Form is not for the faint of heart :)