0

I am using zend framework. I have done user registration and login but i can't do update user information because i don't know how to show form element value in update form.Please tell me any solution.

1 Answer 1

1
    $editClientForm = new Form_AddNewClientForm();
    $editClientForm->setAction($this->view->baseUrl().'/client/edit');
    //fetch client data from your database through model
    $clientInfo = $mdlClient->fetchClientDetails($id);
    //populate the data to form
    $editClientForm->populate($clientInfo); 
    $this->view->editClientForm = $editClientForm;

Update

After taking suggestion of @php-dev:

    $editClientForm = new Form_AddNewClientForm();
    $editClientForm->setAction($this->view->baseUrl().'/client/edit');
    //fetch client data from your database through model
    $mdlClient = new Model_Client();
    $clientInfo = $mdlClient->fetchClientDetails($id);
    //populate the data to form
    $editClientForm->populate($clientInfo); 
    $this->view->editClientForm = $editClientForm;

Inside your model:

    public function fetchClientDetails($id) 
    {
      $row = $this->_db->fetchRow("SELECT * from tablename where id = $id");        

      return $row;
    }
Sign up to request clarification or add additional context in comments.

1 Comment

+1, but you shall mention that populate method accepts an array with fields names as keys and fields values as array values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.