<?php

class frmMessageDemo extends MForm
{
		function __construct() 
		{
			parent::__construct('Message Demo');

			if ( $this->page->isPostBack() )
			{
				$this->eventHandler();
			}
		}

		function CreateFields()
		{
            $fields[] = MMessage::getMessageContainer();
            $fields[] = new MTextField('tf1', '', 'Input field', 20);

			$buttons = array(
				new MButton('btnInfo','Information', ':showInfo'),
				new MButton('btnWarn','Warning'),
				new MButton('btnErro','Error')
			);

			$this->setFields($fields);
			$this->setButtons($buttons);
		}

		function showinfo()
		{
			new MMessage('You clicked the Information button. Field value: '. MForm::getFormvalue('tf1'), MMessage::TYPE_INFORMATION);
			return true;
		}

        function btnWarn_click()
        {
			$msg = array(
                'You clicked the Warning button.', 
                'Field value: '. MForm::getFormvalue('tf1')
            );
            new MMessage($msg, MMessage::TYPE_WARNING);
        }

        function btnErro_click()
        {
            new MMessage('You clicked the Error button!', MMessage::TYPE_ERROR);
        }
}
?>