How do you change the name used for input elements ?

Suppose that we create a form element using:

$lastname = new Text("lastname",array('placeholder' => 'Lastname','name' => "customerLastname"));

This will create a form input element with the name customerLastname, so far so good. But when you bind the $_POST variable to the form it will not recognise the field. Any ideas how to name a field differently in the form then how it was defined in the model ?


why not do this ? $lastname = new Text("customerLastname",array('placeholder' => 'Lastname'));


Because in the model Customers the field is called lastname, which will result in the value not being updated in the model when you do something like:


The reason for this question is that I have 2 entities of a different type with identical field names in one form.... So I have to give one of them a different name but I don't know how to fix this.


$lastname = new Text("aNameIwillChange",array('placeholder' => 'Lastname')); $lastname->setName('customerLastname');

also seems to work.

but what you do here $lastname = new Text("lastname",array('placeholder' => 'Lastname','name' => "customerLastname")); Though the name will change the id of the element won't. No sure if that matters.


i see sorry ... i didn't understand it right