Perforce Chronicle 2012.2/486814
API Documentation

Comment_Form_Comment Class Reference

A form for posting comments. More...

Inheritance diagram for Comment_Form_Comment:
P4Cms_Form

List of all members.

Public Member Functions

 init ()
 Defines the elements that make up the comment form.

Detailed Description

A form for posting comments.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Comment_Form_Comment::init ( )

Defines the elements that make up the comment form.

Called automatically when the form object is created.

    {
        $this->setMethod('post')
             ->setAttrib('class', 'comment-form');

        $this->addElement(
            'hidden',
            'path',
            array(
                'required'  => true,
                'ignore'    => true
            )
        );

        // add name and email fields for anonymous users.
        $anonymous = P4Cms_User::hasActive()
            ? P4Cms_User::fetchActive()->isAnonymous()
            : true;
        if ($anonymous) {
            $this->addElement(
                'text',
                'name',
                array(
                    'label'         => 'Name',
                    'required'      => true
                )
            );

            $this->addElement(
                'text',
                'email',
                array(
                    'label'         => 'Email',
                    'size'          => 50,
                    'required'      => false,
                    'validators'    => array('EmailAddress')
                )
            );
        }
        
        $this->addElement(
            'textarea',
            'comment',
            array(
                'label'     => 'Comment',
                'rows'      => 3,
                'required'  => true
            )
        );

        // require captcha for anonymous users.
        if ($anonymous) {
            $this->addElement(
                'captcha',
                'captcha',
                array(
                    'label'      => 'Verification',
                    'required'   => true,
                    'captcha'    => array(
                        'captcha' => 'Figlet',
                        'wordLen' => 5,
                        'timeout' => 1800
                    )
                )
            );
        }

        $this->addElement(
            'submit',
            'post',
            array(
                'label'     => 'Post Comment',
                'ignore'    => true
            )
        );
    }

The documentation for this class was generated from the following file: