Hi all,
Need some help, i've been looking around all the docs an tutorials but wasn't able to find what i'm looking for.
Creating a site to manage a secondary school, subjects, teachers, etc.
I want to allow teachers connect to the site mysite/manageSubject and add additional information about the subject each teaches.
As there are hundreds of subjects, no sense creating a page for each one, Just one manage page with a drop down where available subjects are selectable.
First of all don't know how to retrieve the item(value) selected in the dropdownField?¿?¿.
How do I load the content stored in a DataObject, therefore in the database when user(teacher) wants to edit its subject information?
Initially i've created a form with a dropdownField(filled with subjects from database) with a submit button (can I align the submit button right beside dropdownField like search form or upload files form?). And now, upon selection, want to load from database any information if exists related with subject, edit, and save it.
I'm quite confused and stuck (two days with SS, - so many information-) and I need some advice and help.
Here is the code.
Thanks a lot.
SubjectManage.php
class SubjectManage_Controller extends Page_Controller {
function SubjectDetailForm() {
// Create fields
$mySet = DataObject::get("Subject");
$dropdownfield = new DropdownField(
'Subject',
'SUBJECT_LABEL',
$mySet->toDropDownMap('ID', 'SubjectName')
);
$fields = new FieldSet($dropdownfield);
// Create actions
$actions = new FieldSet(
new FormAction('SubjectDetailForm', 'Ok')
);
return new Form($this, 'BrowserPollForm', $fields, $actions);
}
function doSubjectForm($data, $form) {
Debug::show($data);
/*How do i get the value selected in dropdownField?*/
}
}
Subject.php
class Subject extends DataObject {
static $db = array(
'SubjectName' => 'Text',
'Calendar' => 'Text',
'Contents' => 'Text'
'Evaluation' => 'Text'
);
static $has_one = array(
'MyTeacher' => 'Teacher',
'MyDepartment' => 'Department'
);
}