ZF-10205: Zend_Form_Element_Note to allow arbatary text in forms
Description
Can Zend/Form/Element/Note.php be added to allow for arbatary text to be added in forms. Example of its use would be to allow a Username to be displayed as non-editable text along side editable text boxes such as Email/Password/Name but have decorators still applied.
class Zend_Form_Element_Note extends Zend_Form_Element_Xhtml
{
public $helper = 'formNote';
}
Comments
Posted by Peter Sharp (stryks) on 2010-07-22T15:51:37.000+0000
Isn't this just a textbox with ...
$element->setAttrib('disabled', 'disabled');
Or is this something else?
Posted by Jonathan Dunn (jmd) on 2010-07-23T02:24:49.000+0000
not really, there are many cases where a text box disabled would still not be appropriate.
Posted by Peter Sharp (stryks) on 2010-07-23T07:35:48.000+0000
Sorry, I didn't really say what I meant to.
It was more a question. What output did you want the element to generate? It's just not very clear what the new element is going to achieve in terms of output.
Posted by Richard Tuin (richardtuin) on 2010-11-19T14:10:36.000+0000
It would make sense to implement this new form element, as displaying a value only can't be solved with decorators.
I have attached the suggested implementation with the associated unit test as a patch.
Posted by Kai Uwe (kaiuwe) on 2010-11-20T08:29:18.000+0000
@Richard Tuin ??I have attached the suggested implementation with the associated unit test as a patch.??
You forgot something: Your note element loses the value after sending the form!
Here's an example to reproduce:
If you are already a registered customer, please sign in.', )); // Button $form->addElement('submit', 'submit', array( 'label' => 'Send', )); if (isset($_POST['submit']) && $form->isValid($_POST)) { // ... } echo $form->render($view);The solution: override the method "isValid".
Posted by Christoph Löffler (loeffler.de) on 2010-11-22T13:09:01.000+0000
I received these files from Kaiuwe, who cannot upload them atm.
Posted by Richard Tuin (richardtuin) on 2010-11-23T12:48:13.000+0000
@Kai Uwe Thank you for your correction.
As for now, no new components will be added to ZF1. I'll will be introduced in ZF 2.0. Changing the fix version to next major.
A 2.0 version of this component should be developed.
Posted by Kai Uwe (kaiuwe) on 2010-12-19T13:17:32.000+0000
New version:
Posted by Frank Brückner (frosch) on 2013-01-10T11:51:22.000+0000
Fixed on trunk (25208) and release-1.12 (25209)
Thanks to Richard and Kai!