Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write hyperlink inside the Zend Form?

I am using Zend-Framework in my project. I made a login form using the Zend Form that contains the User Id and Passwords fields with a submit button. Everything is working fine in the login form.

How do I add two hyperlinks inside the login form that is one for the Sign-Up and other for the Forget Password?

like image 607
Pushpendra Avatar asked May 04 '11 11:05

Pushpendra


2 Answers

I've faced the same problem before, and solved it by creating a custom Zend_Form_Element_Html, as follows:

class Zend_Form_Element_Html extends Zend_Form_Element_Xhtml {
    /**
     * Default form view helper to use for rendering
     * @var string
     */
    public $helper = 'formNote';

    public function isValid($value, $context = null) {
        return true;
    }
}

So, in your form you just have to do the following:

$tag = new Zend_Form_Element_Html('forgetPassword');
$tag->setValue('<a href="/forgotten-pwd">Forgotten your password?</a>');
$this->addElement($tag);

Hope this helps!

like image 197
Joaquín L. Robles Avatar answered Oct 16 '22 17:10

Joaquín L. Robles


In your viewscript file where you print the form, e.g. login.phtml

echo $this->form;

you can specify any other html markup, e.g. links

echo "<p><a href='".$this->url ( array ('controller' => 'authentication',
                                        'action' => 'lostPW' ) )."'>
      Lost pw </a></p>";

So you actually do not write it in the form itself but in the view script where you echo the form.

like image 43
UpCat Avatar answered Oct 16 '22 16:10

UpCat