Validation field label language - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Validation field label language (/showthread.php?tid=76190) |
Validation field label language - maaa.om - 04-20-2020 I have add validation rules in Validation class, like this: public $updateSettings = [ 'site_name' => ['label' => 'site_name', 'rules' => 'required'], ]; Now how I can get label from language file? right now I got error message from /system/Languages, but the issue with label is not take the language from /App/Language. Help me with this, please. RE: Validation field label language - maaa.om - 04-22-2020 NO Answers ?! RE: Validation field label language - jreklund - 04-22-2020 (04-22-2020, 06:56 AM)maaa.om Wrote: NO Answers ?! Take a breather and relax. This are a community based forum. Either no one know your answer, or they don't actually know what you are asking for. Haven't used the language class myself, and based on the description I don't what you want, so I can't recommend any specific part of the user guide. So a good start are writing more in depth and providing more coding examples. RE: Validation field label language - maaa.om - 04-27-2020 (04-22-2020, 10:20 AM)jreklund Wrote:(04-22-2020, 06:56 AM)maaa.om Wrote: NO Answers ?! Thanks for your replay, actually what I want how I can display filed name from my language file in validation message? RE: Validation field label language - jreklund - 04-27-2020 Hi, that part haven't made it to the official user guide. But here's what it says in the development branch: To use translated strings from language files, we can simply use the dot syntax. Let’s say we have a file with translations located here: app/Languages/en/Rules.php. We can simply use the language lines defined in this file, like this: PHP Code: $validation->setRules([ RE: Validation field label language - maaa.om - 04-27-2020 (04-27-2020, 10:25 AM)jreklund Wrote: Hi, that part haven't made it to the official user guide. But here's what it says in the development branch: I did this in Config/Validation.php PHP Code: public $updateSettings = [ But still give site_name, not what site_name in App language file. RE: Validation field label language - jreklund - 04-27-2020 Ok, that's too bad. Haven't tested it myself so can't you any more pointers. RE: Validation field label language - Leo - 04-28-2020 PHP Code: 'site_name' => ['label' => 'App.site_name', 'rules' => 'required'], But still give site_name, not what site_name in App language file. Hi. Not sure, about user guide. When I had to make a custom language thing in my code I wrote like this: 'site_name' => ['label' => lang('language_file.site_name', [], 'language_folder'), 'rules' => 'required'], This was written in controller, so I'm not sure if it answers your question. But you can try it. RE: Validation field label language - maaa.om - 04-30-2020 (04-28-2020, 08:08 AM)Leo Wrote: I can not access lang() function in property declarations: PHP Code: protected $validationRules = [ RE: Validation field label language - michalsn - 04-30-2020 That's why the dot syntax was introduced. If you want to use this feature, be sure to use the latest version from development branch. Or wait until v4.0.3 will be ready. |