As I understood, there are a couple of possibilities to change the field value:
First:
class YourForm extends \Phalcon\Forms\Form
{
// your logic
// has priority 1
public function getCustomValue($name, $entity, $data)
{
if ($name == 'password') return '';
}
// AND/OR...
// @see https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/form.zep#L621
// has priority 2
public function getPassword()
{
return '';
}
}
Second:
class Password extends \Phalcon\Forms\Element\Password
{
// your logic
public function prepareAttributes($attributes = null, $useChecked = false)
{
$default = parent::prepareAttributes($attributes);
return array_merge($default, ['value' => null]);
}
}
Third (if an entity used):
class ExampleModel extends \Phalcon\Mvc\Model
{
// your logic
// @see https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/form.zep#L595
public function getPassword()
{
return '';
}
}
The problem is:
// @see https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/element.zep#L520
/** @var \Phalcon\Forms\ElementInterface $element */
$element->clear();
doesn't work like in versions < 2.x and has no effect on the entity form element.
And
// @see https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/element.zep#L475
$element->_value
is just a default element value with last priority and is set if no any other values given...