跳到内容

EasyAdmin Integer 字段

编辑此页

此字段用于表示存储整数的属性值。

表单页面(编辑和新建)中,它看起来像这样

Default style of EasyAdmin integer field

基本信息

  • PHP 类: EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField
  • Doctrine DBAL 类型 用于存储此值: integersmallint
  • Symfony 表单类型 用于渲染此字段: IntegerType
  • 渲染为:

    1
    <input type="number">

选项

setNumberFormat

默认情况下,整数值“按原样”显示。如果您希望以任何方式格式化该值,请使用此选项并传递任何有效的格式化字符串作为 sprintf() 函数的参数

1
2
3
4
5
6
// this would display integers in scientific notation (e.g. 1234567890 = '1.234568e+9')
yield IntegerField::new('...')->setNumberFormat('%e');

// formatting also helps you to add left/right padding to numbers
// the following example would format 123 as '+00123'
yield IntegerField::new('...')->setNumberFormat('%+06d');

setThousandsSeparator

默认情况下,整数值不会以任何方式分隔千位分组(例如,12345 像这样显示,而不是 12,345)。使用此选项设置用于分隔千位分组的字符

1
2
// this would display '12345' as '12 345'
yield IntegerField::new('...')->setThousandsSeparator(' ');
本作品,包括代码示例,根据 Creative Commons BY-SA 3.0 许可协议授权。
目录
    版本