How to make variables in form only readable

how to make name variable non editable

$name = new Text("name"); $name->setLabel("Name"); $name->setFilters(array('striptags', 'string')); $name->addValidators(array( new PresenceOf(array( 'message' => 'Name is required' )) )); $this->add($name);

edited Oct '16

if you mean not editable input element, you need html input disabled attribute, I think

try something like:

$name = new Text("name", ['disabled' => 'disabled']);

Pay attention to difference between disabled and readonly HTML5 attributes. If you only want to display locked input field, use disabled, since if you use readonly it will be also locked to the user, but the value of the field will still be POSTed on submit of the form. With disabled it won't even be present in POST.