tags:

views:

585

answers:

1

Hi,

i am using a CakePHP form Creator


echo $form->input($r['Attribute']['label'], array('id'=>$r['Attribute']['id'],'name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));

echo $form->input($r['Attribute']['label'], array('label'=>false,'div' => false,'id'=>$r['Attribute']['id'].'-','name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));

which creates a Input Box and the generated Html is like

 <div class="input text">
   <label for="6">Mobile Number</label>
   <input type="text" value="" style="width: 30px;" id="6" name="Mobile Number"/>
</div>
<input type="text" value="" style="width: 30px;" id="6-" name="Mobile Number"/>

But i need this second input Text Box to appear inside the above Div ..Please suggest me.

+3  A: 
<div class="input text">
    <?php
    echo $form->input($r['Attribute']['label'], array('id'=>$r['Attribute']['id'],'name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px', 'div' => false));
    echo $form->input($r['Attribute']['label'], array('label'=>false,'div' => false,'id'=>$r['Attribute']['id'].'-','name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));
    ?>
</div>

Note that I've added 'div' => false to the first input too.

But wouldn't this give you two inputs with the same name?

dr Hannibal Lecter
I have created like what you said how can i retrive its full value?I am retrieving the values in my Cakephp controller using $_POST
Mercy
Mercy, if you're using $_POST you didn't even read the basic cake tutorial. You're supposed to use $this->data. At *least* go through the basic blog tutorial (http://book.cakephp.org/view/219/Blog) before coding a real app.
dr Hannibal Lecter
foreach ($_POST as $key => $value):if(is_array($value)){$value = implode('', $_POST[$key]);$this->data['Result']['value']=$value;}else{$this->data['Result']['value']=$value;}$this->data['Result']['form_id']=$formid;$this->data['Result']['label']=Inflector::humanize($key);$this->Form->submitForm($this->data);endforeach;I have used the above and got it.
Mercy