2014-01-29 25 views
1

我想在Symfony2包中的一個表單的屬性驗證選項(在標準的src/site/BundleName/Resources/config/validation中)寫入。 yml文件),我想知道如何將語句分成兩行。原因如下:如何在Symfony2 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文件中分割行/語句的正確語法?它甚至有可能嗎?

回答

3

也許反斜槓會讓你逃脫回車,但恕我直言,你應該這樣做:

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

不幸的是,反斜槓不離開回車。儘管我有足夠的聲譽,但我會在1分的時候把你的答案加1 – DIMMSum