[Don't want to discourage anyone else from dropping input, but (let's face it) Willr's answers are guaranteed to be impeccable.]
After thoroughly following the tutorials and reading and re-reading the official book, I am still having trouble understanding the difference in functionality between the model and controller portion of the MyPage.php file. I do understand that the model handles the content and the controller handles the processing of data (as per http://doc.silverstripe.org/framework/en/tutorials/2-extending-a-basic-site). Intuitively, it would seem that only the form information and attributes should go in the model portion and the submit function should go in the controller. After viewing numerous code snippets, it seems to be possible to do it either way (but this is the most common). Also having trouble understanding proper DataObject creation. Should it be in its own file for permanent reference, or is it supposed to be declared in the Code/MySite.php file (which seems more temporary, so-to-speak).
The Final Goal: Have a 'userprofile' table to store individual user information and a 'profiledatabase' table to nest the 'userprofile' tables into (much like the ArticlePage and ArticleHolder in the aforementioned tutorial link). The form should then create a 'userprofile' object, write the form information into the corresponding attributes of the 'userprofile' object, and then write that 'userprofile' table/object into a new row of the 'profiledatabase' table/object. I'm thinking I might also need to store the username as a separate field in the 'profiledatabase' for profile lookup, assuming I store the whole 'userprofile' object in the 'profiledatabase' as its own attribute (please confirm). Otherwise, the 'userprofile' attributes would need to be written across the columns of the row for that particular 'userprofile'. Before this post gets any longer, please correct any incorrect assumptions (or confirm correct ones) that I have made in the previous paragraphs and then take a look the actual code. The form submit result is posted after the code,
Now to the implementation:
*Note: This is a mix of code inspired from both the tutorial previously mentioned as well as material found in the Official SilverStripe Manual (complete Guide to CMS Development) from pages 146-150.
1: Database Creation
class UserProfile extends DataObject
static $db = array(
class ProfileDatabase extends DataObject
//Not sure about this yet
2: UserForm.php Page/Controller
class UserForm extends Page
$fields = new FieldList(
new TextField('First Name:'),
new TextField('Middle Name:'),
new TextField('Last Name:'));
$actions = new FieldSet(new FormAction('submitUserForm', 'Submit'));
$validator = new RequiredFields('First Name', 'Last Name');
$form = new Form($this, 'Form', $fields, $actions, $validator);
class UserForm_Controller extends Page_Controller
function submitUserForm($data, $form)
$userprofile = new UserProfile();
// Almost certain this next line is way wrong
$userprofile->UserRegistrationFormID = $this->dataRecord->ID;
$form->sessionMessage('Form Submitted Successfully', 'good');
3: UserForm.ss Layout
<div id="User Form">
CANNOT GET MUCH SIMPLER THAN THIS.
The form displays correctly when called for and the database tables seem to appear created in phpmyadmin, but when clicking submit, I am redirected to the page:
Page not found - Sorry, it seems you were trying to access a page that doesn't exist. Please check the spelling of the URL you were trying to access and try again.
--and the tables displayed in phpmyadmin are not updated with the information in the form.
"Willr" you please work your magic? Sorry about the formatting, the indentations aren't appearing.