Problem Adding a Button (linked to new php Page) inside a Block

Problem Adding a Button (linked to new php Page) inside a Block

by Qadeer Ahmad -
Number of replies: 1

This is my code, the problem that I am facing adding a button is unexpected '<' error. Is there any solution.
One more thing is that Can I add this Button inside a table class of a block.

$newtext1=<input name="View Attendance" type="button" value="new Discussion" align="center" onclick="windows.open('/segp_attendance/result_card.php')"/>;

$this->content->text.=$newtext1;

Thanks.

Average of ratings: -
In reply to Qadeer Ahmad

Re: Problem Adding a Button (linked to new php Page) inside a Block

by tim st.clair -
Picture of Plugin developers

Using the internal methods for building your output can help minimise these types of errors, for instance use html_writer

$button = html_writer::empty_tag("input", array(
    "name" => get_string("View Attendance", "my_plugin"),
    "type" => "button",'
    "value" => "New Discussion",
    "class" => "text-center",
    "onclick" => "window.open('" . new moodle_url("/segp_attendance/result_card.php") . "')",
));
$this->content->text .= $button;

We can help you put this in a different place in your block if you show us some more code - where precisely do you want it?