使用Symfony 3,如何显示只读字段作为标签? (在FOSUBundle的注册表中) [英] With Symfony 3, how to display a read-only field as a label ? (in FOSUBundle's registration form)

查看:60
本文介绍了使用Symfony 3,如何显示只读字段作为标签? (在FOSUBundle的注册表中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Symfony 3和覆盖的FOSUserBundle的注册表格,我有一个只读字段:

Using Symfony 3 and overridden FOSUserBundle's registration form, I have a readonly field:

->add('name', TextType::class, array('attr' => array('readonly' => true)))

目前,它显示为文本框,但我希望它显示为文本/标签.我什么也看不到,例如"LabelType".可以这样做吗?

For now, it appears as a textbox, but I would like it to appear as a text/label instead. I see nothing such as "LabelType". Is it possible to do this?

推荐答案

在具有readonly属性的情况下,您似乎需要自定义文本框的外观.因此,简单的解决方案可以是单一CSS样式:

It look like you need customize the appearance of the textbox when it has the readonly attribute. So the simple solution could be a single CSS style:

// style.css
input[readonly] {
    border: none;
    // more custom styles
}

我的意思是,无需在Symfony中做一些特别的事情,并且对所有输入的只读表单字段都有用.

I mean, there is no need to do something special in Symfony and could be useful for all input readonly form fields.

这篇关于使用Symfony 3,如何显示只读字段作为标签? (在FOSUBundle的注册表中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆