Going through the tutorial completely with creating your example Custom Table and XpdoClasses my [[CreateQuote]] Snippet looks like this:
<?php
global $modx;
if (isset($_POST['submit']) && ($_POST['submit'] == 'submit')) {
/* Form has been submitted */
/* You might want to check for empty required fields here */
$fields = array(
'topic' => $post['topic'],
'quote' => $post['quote'],
'author' => $post['author'],
);
$quote = $modx->newObject('Quotation', $fields);
if ( $quote->save()) {
$output = "Quote Created";
} else {
$output = "Error";
}
} else {
/* Not a repost, just display the form */
$output = $modx->getChunk('quotationTpl');
}
return $output;
But is giving the following error
Fatal error: Call to a member function save() on a non-object in C:\wamp\www\modx\core\cache\elements\modsnippet\38.include.cache.php on line 20
Which is:
if ( $quote->save()) {
I am also calling it from a page under resources
<form method="post" action="[[CreateQuote]]">
<textarea rows="5" cols="35" name="topic" id="topic"></textarea>
<textarea rows="5" cols="35" name="quote" id="quote"></textarea>
<textarea rows="5" cols="35" name="author" id="author"></textarea>
<input type="submit" name="submit" id="submit" value="submit"/>
</form>
Honestly not quite sure what to do with the [[quotationTpl]] chunk. Currently the only code thats in the chunk is [[CreateQuote]]