Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

disable password required

i have form with password field


$object = (new Object)->getOne($id);
$form = new EditForm();


$this->add((new Password('password', [
                'required' => false,
                'class' => 'form-control input-md'

after render

<input type="password" id="password" name="password" value="password hash" class="form-control input-md" required="" />
  1. how disable password required?
  2. how set empty password value, when i edit object?

edited May '15

If you remove "required" => false completely from the form setting, it should remove it from the output.

$this->add(new Password('password',
    [ 'class' => 'form-control input-md' ]

As for not having the password field auto-populated, you can do a few things. I've done both in the past:

Idea #1:

Do not name your password field password. Name it something like password_update.

$this->add(new Password('password_update',
    [ 'class' => 'form-control input-md' ]

Then in your controller check for $this->request->getPost("password_update").

 class SomeController extends \Phalcon\Mvc\Controller {

    // Some action in your controller that the form was posted to
    function someotherAction(){
        $object = (new Object)->getOne($id);

        $form = new EditForm($object);
        // $form->setEntity($object);

        // Check to see if the form was posted

            // Check to see if the form is valid

                // Set the standard fields

                // Store the new password value into $password_update variable for reuse
                $password_update = $this->request->getPost('password_update');

                // Check to see if a password was submitted/updated
                    // If a new password was posted, set the new password in the object

                // Update/save the object
                    // Object Update Failed - Flash the error messages here
                    $errors = [];
                    foreach($object->getMessages() as $message){
                        $errors[] = $message->getMessage();
                    $this->flash->error(implode('<br />', $errors));
                } else {
                    // Save succeeded - Flash success
                    $this->flash->success('Record was updated successfully');
            } else {
                // Form validation failed - flash the error messages here
                    $errors = [];
                    foreach($form->getMessages() as $message){
                        $errors[] = $message->getMessage();
                    $this->flash->error(implode('<br />', $errors));


        $this->view->form = $form;
        $this->view->object = $object;

Idea #2:

Physically type out the input password tag, do not have it go through the phalcon form with no default values