Need Help about Form->control("")


#1

If I specify a character string containing underbar in Form-> control (""), the character string after underbar will not be displayed as a label.
The same result will be obtained even if it is “\ _”.
Could you tell me how to display the character string after underbar ?

code> Form-> control (“xxxx_yyyy”)
result> Xxxx

code> Form-> control (“xxxx\_yyyy”)
result> Xxxx\

Desired results>xxxx_yyyy


#2

Have you tried to use escape ?

echo $this->Form->control(‘name’, [
‘escape’=>false
]);


#3

Thank you for your reply.
I try following 3 code,

  1. echo $this->Form->control(“xxx_yyy”);
    Xxx Yyy
  2. echo $this->Form->control(“xxx_yyy”,[‘escape’ => false]);
    Xxx Yyy (same as 1)
  3. echo $this->Form->control(“xxx_id”,[‘escape’ => false]);
    Xxx

case 1,2 : underbar -> white space
case 3 : when string after underbar is “id”, underbar + “id” is not displyed.
This is the first case I asked.

Is there a way(by Form->control() ) to display the specified character string as it is?


#4

I’m not sure at all but maybe the method $this->Form->control() is the problem. Have you tried to use a specific method for a type of field like echo $this->Form->text() ?


#5

Thanks for your reply.
As a workaround, I temporarily decided to get through with the following code.

[workaround code]
echo $this->Form->label(“xxxx_id”,array(‘label’ => ‘xxxx_id’));

echo $this->Form->text(“xxxx_id”);

if I specify [xxxx_id] for Form-> control (), it will be interpreted as the ID of [xxxx] table, and [listbox] will be displayed instead of [textbox].