Help! I've built a form in the latest release of SS and now I'm having trouble saving the information where I have 'Optionsetfield', all the other field types save perfectly ok.
I've used these before and not encountered this so I guess I'm just missing something here but on reading the documentation I can't spot anything.
Here is my code:
public function ResultsEditForm(){
$urlAction = Director::URLParam('Action');
$urlID = Convert::raw2sql(Director::urlParam('ID'));
if(is_numeric($urlID)){
$Contact = $caseInfo->Contact;
}
// Create fields for edit form
$fields = new FieldSet(
new OptionsetField(
$name ='Contact',
$title = 'Contact',
$source = array(
"1" => "Yes",
"2" => "No"
), $value = $Contact)
);
$actions = new FieldSet(
new FormAction("UpdateCase", "Update")
);
return new Form($this, "ResultsEditForm", $fields, $actions);
}
// Function to write our data
public function UpdateCase($data, $form){
$id = (int)$_REQUEST['CaseID'];
$caseInfo = DataObject::get_by_id('myFifth', $Case->myFifthID);
$caseInfo->Contact = $data['Contact'];
$caseInfo->write();
}
Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
}
public function Success(){
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
}
I think I've included everything above, I've not posted the other fields as this post would be very very long.
I've tried making the OptionsetField a DropdownField to see how they differ and it made no difference when saving.
I'm close to a deadline here so quite anxious, this is the only thing holding me back, any help much appreciated, thanks.