Hey everyone!
With my code (http://pastebin.com/m3e33dbd4) it comes up with this error:
The website server has not been able to respond to your request.
It seems to be a problem with $dataobjectset->toArray()
- David
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hey everyone!
With my code (http://pastebin.com/m3e33dbd4) it comes up with this error:
The website server has not been able to respond to your request.
It seems to be a problem with $dataobjectset->toArray()
- David
You've got a lot of HTML in the PHP code. This could be offloaded to the templates, which makes life a lot easier!
Generally it's better to return a DataObject (or DataObjectSet) from the function in your controller, and then using that in the templates with a <% control %> loop.
e.g.
<?php
class ReportPage extends Page {
}
class ReportPage_Controller extends Page_Controller {
function ViewInfo() {
$userid = (int) $_GET['id'];
return DataObject::get_one('MedCheck', "UserID = {$userid}");
}
}
?>
Then, in your template (ReportPage.ss inside templates/Layout):
<% if ViewInfo %>
<% control ViewInfo %>
$SomePropertyHere $ID
<% end_control %>
<% else %>
<p>No view info (insert better text here ;-))</p>
<% end_if %>
$SomePropertyHere refers to some item in your $db or $has_one or similar array on the MedCheck class, which I assume is a DataObject or a Page subclass.
I'm sure you'll have questions. Please do reply!
:-)
Sean
- When you use <%control... isn't that a foreach sort of function? Is it necessary since you are using DataObject::get_one?
EDIT: I've figured out a heck of a lot of things I posted here, it's awesome!
Also, I would like have a WYSIWYG editor in my website, is there an easy way to do that?
-I'm guessing manually. What database field type would suit this?