tags:

views:

256

answers:

2

Hi,

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 recitified the error...

A: 

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.

Wayne Khan
No i am keeping the label name as Last name and i want to posted as the same(Last name and not as Last_name) so that for future Use
A: 

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

See api.cakephp.org.

jimiyash