CodeIgniter Forums
Form validation, get label - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form validation, get label (/showthread.php?tid=13937)



Form validation, get label - El Forum - 12-12-2008

[eluser]Mat-Moo[/eluser]
Is there a way to use you field name via the form_validation unit (or helper) to get the "Label" for it? Like $this->form_helper->Get_Label('field')?


Form validation, get label - El Forum - 12-12-2008

[eluser]xwero[/eluser]
You can create your own function for this but be aware of the lang: prefix functionality of the label field.


Form validation, get label - El Forum - 12-18-2008

[eluser]Mat-Moo[/eluser]
Any clues on this? I know I can create a function, but I don't know where the data is...


Form validation, get label - El Forum - 01-06-2009

[eluser]Mat-Moo[/eluser]
Anyone help me on this?


Form validation, get label - El Forum - 01-06-2009

[eluser]xwero[/eluser]
the data is in the _field_data[$field]['label'] Form validation class variable. You can extend the class with a label method and add a label method to the form helper that takes care of the html generation.

But if you store all your labels in language files you can use the language helper to generate the html. With this approach you don't need to extend the framework and you don't have to change code if more languages are needed.


Form validation, get label - El Forum - 01-06-2009

[eluser]Mat-Moo[/eluser]
Thanks