【问题标题】:How to split a statement across two lines in Symfony2 validation.yml file如何在 Symfony2 validation.yml 文件中将语句拆分为两行
【发布时间】:2014-02-21 20:09:00
【问题描述】:

我正在尝试为 Symfony2 包(在标准 src/site/BundleName/Resources/config/validation.yml 文件中)中的表单编写属性验证选项,我想知道如何将语句拆分为两个线。照原样,这是:

department:
        - Type: string
        - Choice:
            choices: ['Customer Service', 'Development', 'Finance', 'Human Resources', 'Marketing', 'Production', 'Quality Management', 'Research', 'Sales']

正确编译。但是,当我尝试这样拆分语句时:

department:
    - Type: string
    - Choice:
        choices: ['Customer Service', 'Development', 'Finance', 'Human Resources', 'Marketing', 'Production',
                  'Quality Management', 'Research', 'Sales']

(将“质量管理...”移至下一行并缩进)我收到以下错误:

Malformed inline YAML string ['Customer Service', 'Development', 'Finance', 'Human Resources', 'Marketing', 'Production', at line 25 (near "choices: ['Customer Service', 'Development', 'Finance', 'Human Resources', 'Marketing', 'Production',")
500 Internal Server Error - ParseException

有人知道在 .yml 文件中拆分行/语句的正确语法吗?有可能吗?

【问题讨论】:

    标签: symfony yaml


    【解决方案1】:

    也许反斜杠会让你逃避回车,但恕我直言,你应该这样做:

    department:
        - Type: string
        - Choice:
            choices:
                - 'Customer Service'
                - 'Development'
                - 'Finance'
                - 'Human Resources'
                - 'Marketing'
                - 'Production'
                - 'Quality Management'
                - 'Research'
                - 'Sales'
    

    【讨论】:

    • 不幸的是,反斜杠没有逃脱回车。不过,当我有足够的声誉时,我会给你的答案投票 1 分:p
    猜你喜欢
    • 2012-03-13
    • 1970-01-01
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-09
    相关资源
    最近更新 更多