Zend Framework: how to create a sub form with a textfield with label and a submit button without?
$sfKeyword = new Zend_Form_SubForm();
// text field
$tfKeyword = $sfKeyword->createElement('text', 'keyword');
$tfKeyword->setLabel('Search Keyword:');
// add elements
$sfKeyword->addElement($tfKeyword);
$sfKeyword->addElement('submit', 'submitSqlKeywordCheckerForm', array('label' => 'Check'));
// p开发者_如何学运维repend labels
$sfKeyword->setElementDecorators(array(
'ViewHelper',
'Errors',
array('Label', array('placement' => 'prepend')),
));
I want to display a GUI like
[textfield label] [textfield] [submit button]
but the following gets displayed:
[textfield label] [textfield] [submit button label] [submit button]
The problem with the above code is that the submit button needs a label which is used on the button, but I don't want a label to be shown left to the button, which can't be circumvented with the decorator
array('Label', array('placement' => 'prepend')),
I basically have two options:
Suppress the submit button's textual label (not the one inside the button) OR
Delete the label decorator and manually add a simple text before the textfield
I have no idea how to add simple text to a form without a hidden input, which then must be labeled, too, so that doesn't help either.
How do I do it? Thanks
If you want to remove the label for submit button only try this:
$sfKeyword->getElement('submitSqlKeywordCheckerForm')->removeDecorator('label');
Hope this will be of help to you.
精彩评论