Project / Support Center
Welcome, Guest. Please login or register. October 03, 2023, 04:34: AM
Home Help Search Login Register
D-Web Web Site Creator D - Web Web Site Creator On-line HTML Editor No Programming knowledge required. Web Global Net PayPal-Cart Shopping Cart System PayPal - Kart Shopping Cart System for E-Commerce over the internet, that's easy to use. Web Global Net Newsletter Manager Newsletter Manager On-line Newsletter Creator with Email Subscriber Management.
Ring Central Discount
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Zend Framework  |  Topic: display text (value attribute) for the submit element 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Send this topic Print
Author Topic: display text (value attribute) for the submit element  (Read 23869 times)
admin
Guest
« on: November 20, 2009, 12:13: PM »

Creating a new form within the Zend framework. You can run into a bit of trouble with the display text (value attribute) for the submit element when it comes to invoking the Zend_Form_Element_Submit() method. Like usual, when it comes to frameworks and other types of plug-ins, things don’t work out like you normally would think they should.

 Web application developers are constantly battling the inconsistent semantics from the syntax. The same concept as out of the norm‚Ķ

Code Examples:
The below code represents the submit buttons display text. It has always been that the input type submit element‚Äôs attribute of value is what displays the button‚Äôs text however when using the Zend framework‚Äôs Zend_Form class, you must use the setLabel method. See where  lines 8 and 9 in Red are commented out, where normally one would think to set the attribute for value to show the display? You may have tried both methods the setValue and setAttrib and both to your surprise had no effect to the button‚Äôs display text (normally using the value attribute).

The Fix:
In order to overcome this minor problem, you must use the setLabel method which also generates the label tags for each form element. So the ZFW requires that you use this same method to set the text display within the button.



< ?php
class LoginForm extends Zend_Form
{
       public function __construct($options = null)
      {
            $submit = new Zend_Form_Element_Submit('submit');
           //$submit->setValue('Login');
           //$submit->setAttrib('value', 'Login');

           $submit->setLabel('Login');
           $this->addElements(array($username, $password, $submit));
       }
}
?>

Conclusion
Even though this problem could potentially throw off many web developers that are new to this framework, it still has it’s purpose in their design logic. They must have designed it this way to keep the consistency within their own framework. The setLabel method is used on almost every form element so it would be consistent enough to use this same method on the submit type input elements. Hope this helps everyone that had encountered this same issue.
« Last Edit: November 20, 2009, 12:32: PM by Web Global Net » Report to moderator   Logged
Pages: [1] Go Up Send this topic Print 
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Zend Framework  |  Topic: display text (value attribute) for the submit element « previous next »
Jump to:  


Login with username, password and session length
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!