0
votes

I am using Cakephp and jQuery in my application.

I am having a Form generated in cakePhp. I got the posted values of this form using

echo http_build_query($_POST);

If my form has any field with name as Firstname it is posted as correctly,

But when i have any field in the form with the name as Last name (i.e. with spaces in between ) then ,it is posted like Last_name.How to rectify this error..

My form is generated using

<?php
    echo $form->create('Result',array('id'=>"ResultSubmit",'action'=>"submit/".$formid."/".$userid));
?>

<?php foreach ($viewfields as $r): 
    echo $form->input($r['Attribute']['label'], array('id'=>$r['Attribute']['id'],'name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:' . $r['Attribute']['size'] . 'px'));
?>
<?php endforeach; ?>
<?php echo $form->end('submit');?>

i kept the name for my input field using 'name'=>$r['Attribute']['label']//where it notifies the Label for the field Eg Firstname or Last name

I think i got the cause of the error may be keeping the name ..But how to do so..

Edit:

I have used the Humanize concept in CakePhp and rectified the error...

2
"Jasmine" being Aruna I presume? If so, I assume your account has been suspended for a good reason. Another account is not the solution.dr Hannibal Lecter
Ya i dont know the reason why i have been suspended form this StackOverflow..Jasmine

2 Answers

0
votes

By convention, I do design my tables with underscored names; e.g.

users.first_name
users.last_name

I do not use spaces in names -- I don't believe they are supported in HTML anyways -- so I've not encountered the problem.

If the sole intention of having spaces in the field name like "First name" is strictly for labels, CakePHP does humanize the label names, so a field name of "first_name" would be converted like "First Name".

Hope this helps.

0
votes

Maybe, you could use $form->text instead of $form->input because $form->input does a lot of extra things.

See api.cakephp.org.