Your Location is: Home > Cakephp-2.4

cakephp 2.x FormHelper radio ID

From: Macedonia View: 4269 luchao 

Question

When I use cakephp FormHelper like this

echo $this->Form->radio('searchDateType',array('0'=>'test0','1'=>'test1'),array(
                                'separator'=>' ','default'=>2,'legend'=>false'));

I hope to get like this

<input type="radio" name="data[Project][searchDateType]" id="ProjectSearchDateType0" value="0" checked="checked">
<label for="ProjectSearchDateType0">test0</label>&nbsp;
<input type="radio" name="data[Project][searchDateType]" id="ProjectSearchDateType1" value="1">
<label for="ProjectSearchDateType1">test1</label>

But in one of my centos server I get this

<input type="radio" name="data[Project][searchDateType]" id="ProjectSearchDateType" value="0" checked="checked">
<label for="ProjectSearchDateType">test0</label>&nbsp;
<input type="radio" name="data[Project][searchDateType]" id="ProjectSearchDateType" value="1">
<label for="ProjectSearchDateType">test1</label>

The IDs are the same

Then I find the wrong is in Inflector::slug

preg_replace(array_keys($map), array_values($map), $string);

This return empty.

I don't know what's wrong with it,counld someone help me to solve it

Best answer