- I am doing:- block_message_to_self_form.php
<?php
require_once("$CFG->libdir/formslib.php");
class message_form extends moodleform {
function definition() {
global $CFG;
$mform =&$this->_form;
$mform->addElement('textarea', 'message', get_string("message_to_self", "block_message_to_self"), 'wrap="virtual" rows="5" cols="10"');
$mform->addElement('button', 'messagesave', get_string("message_save", "block_message_to_self"));
}
}
- I want to display this form in block class file block_message_to_self.php.
require_once('block_message_to_self_form.php');
class block_message_to_self extends block_base {
/**
* block initializations
*/
public function init() {
$this->title = get_string('pluginname', 'block_message_to_self');
}
public function get_content() {
global $CFG, $USER, $COURSE, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
if (!isloggedin()) {
return '';
}
$this->content = new stdClass;
$this->content->text = 'Hello';
$this->content->footer = '';
$course = $this->page->course;
$simplehtml = new message_form();
$this->content->text.=$simplehtml->display(); // this form is not displaying in block
return $this->content;
}
}
Please help me.