Zend Framework:如何创建一个带有带标签的文本字段和不带提交按钮的子表单?
$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'));
// prepend labels
$sfKeyword->setElementDecorators(array(
'ViewHelper',
'Errors',
array('Label', array('placement' => 'prepend')),
));
我想显示一个像这样的 GUI
[textfield label] [textfield] [submit button]
,但显示以下内容:
[textfield label] [textfield] [submit button label] [submit button]
上面代码的问题是提交按钮需要一个在按钮上使用的标签,但我不希望在按钮左侧显示标签,这是装饰器无法绕过的
array('Label', array('placement' => 'prepend')),
我基本上有两个选择:
抑制提交按钮的文本标签(不是按钮内部的标签)或
删除标签装饰器并在文本字段之前手动添加简单文本
我不知道如何将简单文本添加到没有隐藏的表单中输入,然后也必须被标记,所以这也没有帮助。
我该怎么做? 谢谢
$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'));
// prepend 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想删除提交按钮的标签,只需尝试以下操作:
希望这对您有帮助。
If you want to remove the label for submit button only try this:
Hope this will be of help to you.