How to get the textbox label implemented using helper in cakephp?


For example :



  //in my view
 echo $form->input('Model.field', array('label' => 'The label', 'id'=>'txtID'));
 $valueOfLabel = ??????? // how to get the label text which is 'The label'

i want to get the "The label" which is the label of the inputbox and store it to a php variable

How can i get it? Is it possible?

Any help would be greatly appreciated Thanks :D

If you're setting the label yourself as you're showing in the question, then Pawel's answer is correct. Save the value in a variable yourself.

If you're interested in the auto-generated label for a field, this information is not saved anywhere (which is why you can't "get the value"), it's simply output. You could regenerate it using Inflector::humanize('fieldname'), which is what the FormHelper uses internally.

You could get the output using output buffering and parse it to extract the output value, but if you're actually doing that, you're insane! Go with Pawel's answer! :-P