ProfileForm::init PHP Method

init() public method

public init ( )
  public function init() {
    $user=Zend_Auth::getInstance()->getIdentity();
    $username = $this->addElement('text', 'username', array(
      'filters'  => array('StringTrim', 'StringToLower'),
      'validators' => array(
        'Alnum',
        array('StringLength', false, array(3, 20)),
      ),
      'required'   => true,
      'label'    => 'Your username:',
      'readonly'   => 'true',
      'value'    => $user->getId(),
    ));

    $display_name = $this->addElement('text', 'display_name', array(
      'filters'  => array('StringTrim'),
      'required'   => false,
      'label'    => 'Display Name:',
      'value'    => $user->getDisplayName(),
    ));

    $password = $this->addElement('password', 'password', array(
      'filters'  => array('StringTrim'),
      'required'   => false,
      'label'    => 'Password:',
    ));

    $email = $this->addElement('text', 'email', array(
      'filters'  => array('StringTrim'),
      'validators' => array('emailAddress'),
      'required'   => false,
      'label'    => 'Email:',
      'value'    => $user->getEmail(),
    ));

    $email = $this->addElement('text', 'location', array(
      'filters'  => array('StringTrim'),
      'required'   => false,
      'label'    => 'Location:',
      'value'    => $user->getLocation(),
    ));

    $email = $this->addElement('text', 'webpage', array(
      'filters'  => array('StringTrim'),
      'required'   => false,
      'label'    => 'Webpage:',
      'value'    => $user->getWebpage(),
    ));

    $email = $this->addElement('text', 'avatar', array(
      'filters'  => array('StringTrim'),
      'required'   => false,
      'label'    => 'Avatar (URL):',
      'value'    => $user->getAvatar(),
    ));

    $login = $this->addElement('submit', 'save', array(
      'required' => false,
      'ignore'   => true,
      'label'  => 'Save',
    ));

    // We want to display a 'failed to save' message if necessary;
    // we'll do that with the form 'description', so we need to add that
    // decorator.
    $this->setDecorators(array(
      'FormElements',
      array('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')),
      array('Description', array('placement' => 'prepend')),
      'Form'
    ));
  }
ProfileForm