2

Using this code inside my validation.php, I was able to translate the translate the values of the edit_type-field:

'values' => [
    'edit_type' => [
        '1' => 'Intern',
        '2' => 'Kunde'
    ],
    'every_day' => [
        'true' => 'ausgewählt',
        'false' => 'nicht ausgewählt'
    ]
],

But for some reason, the same logic does not work for the every_day field. I assume it has something to do with the values being booleans.

This is usually used with required_if inside the validation, in the case of every_day I use required_unless which should not make a difference.

Any idea how I can accomplish this?

molerat
  • 946
  • 4
  • 15
  • 43

2 Answers2

1

As explained here

... in PHP, the boolean value true is displayed as 1 and the boolean value false is displayed as the empty string (i.e. nothing is displayed)

So, you can map boolean values like this

'values' => [
    'every_day' => [
        '1' => 'ausgewählt',
        '' => 'nicht ausgewählt',
    ],
],
0

Try this. I think this will help

'values' => [
'edit_type' => [
    '1' => 'Intern',
    '2' => 'Kunde'
],
'every_day' => [
    true => 'ausgewählt',
    false => 'nicht ausgewählt'
]
],
Chirag Patel
  • 1,545
  • 2
  • 9
  • 17