PHP:将ZendFormElementText的标签放在元素的右侧


PHP: Placing the label of a Zend Form Element Text to the right of the element

我正在为uni做一个项目,作为其中的一部分,我正在翻译一些页面,并在RTL中需要它们。

这些文本字段是在另一个文件的类中声明的。

我已经成功地将调用页面设置为RTL(使用[html dir='rtl']),它将所有元素移动到页面的右侧,但文本元素的标签在其左侧,并与页面的左侧对齐。

在该文件中使用[html dir='rtl']没有任何效果。

以下是代码的相关部分(我认为):

$keywords = new Zend_Form_Element_Text('keywords' , array('size' => '30'));
$keywords->setLabel('Keywords from Abstract')
->addFilter('StripTags')
->addFilter('StringTrim')
->setDescription('Enter one or more keywords, separated by whitespace.')
;
// Definition of additional (almost identical) elements
$this->addElements(array(..., $keywords , ... ));
$this->setDecorators(array(
'FormElements',    
array('HtmlTag', array('tag' => 'dl', 'class' => 'search')),
array('Description', array('placement' => 'prepend')),
'Form'
));

如何将标签移动到文本元素的右侧?

请注意,我已经尝试将最后一行更改为"placement"=>"append",这似乎没有改变任何内容。

提前感谢

您可以通过以下方式更改label装饰器的位置:

$decorator = $keywords->getDecorator('Label');
if ($decorator) $decorator->setOption('placement', Zend_Form_Decorator_Abstract::APPEND);

然后更改样式以获得正确的格式输出:

form dd {display: inline-block; width: 60%;}
form dt {display: inline-block; width: 35%;}