Jonathan
Jonathan

Reputation: 4918

Function that creates a input name from a string in CakePHP

I would like know if there is a function in CakePHP that transforms Mymodel.Mycolumn into data[Mymodel][Mycolumn].

I know how to do this with PHP only, but I would like to know if there is a built-in CakePHP function for it.

EDIT:
I don't need the input, only the name.

Upvotes: 0

Views: 54

Answers (2)

CoolLife
CoolLife

Reputation: 1479

if you're sending, you can do this:

 <?php 
        echo $this->Form->create('Mymodel');    
        echo $this->Form->input('Mymodel.Mycolumn', array('label' => 'add data for Mycolumn'));
        echo $this->Form->submit('submit', array('class' => 'form-submit',  'title' => 'Enter')); 
 ?>

Upvotes: 0

AbraCadaver
AbraCadaver

Reputation: 78994

See the pretty complete CakePHP Cookbook. To use the current model:

echo $this->Form->input('Mycolumn'); 

Or to specify the model:

echo $this->Form->input('Mymodel.Mycolumn');

Creates:

<input type="text" id="MymodelMycolumn" name="data[Mymodel][Mycolumn]">

Upvotes: 1

Related Questions