Reputation: 141
That's it. I googled. I didn't find anything.
Upvotes: 0
Views: 372
Reputation: 9715
yes absolutely you need to add additional property for field.
you can find whole reference here : https://octobercms.com/docs/backend/forms#field-switch
my_switch:
label: Yes/No
type: switch
comment: Just Example
on: myauthor.myplugin::lang.models.mymodel.my_switch.on <- this
off: myauthor.myplugin::lang.models.mymodel.my_switch.off <- n this
now for in language file refer this : https://octobercms.com/docs/plugin/localization#file-structure
you need to add language string for that. OR you can directly apply it if you don't want it for multi language
my_switch:
label: Yes/No
type: switch
comment: Just Example
on: Yes <- this
off: No <- n this
Above example is only for single form field switch.
To make it work whole site wide in back-end, please refer this : https://octobercms.com/docs/plugin/localization#overriding
you need to create new language file
lang/ <=== App localization directory
en/ <=== Language directory
backend/ <=== Plugin / Module directory
lang.php <=== Localization override file
and you need to add this language array to override text, lang.php file content
<?php
return [
'form' => [
'field_off' => 'Off',
'field_on' => 'On'
]
];
if any doubt please comment.
Upvotes: 1
Reputation: 631
you just need to pass values for on and off text properties.
suppose you have below field in yaml file.
show_content:
label: Display content
type: switch
on: 'Yes'
off: 'No'
you can also learn from documentation https://octobercms.com/docs/backend/forms#field-switch
Upvotes: 1