I have a simple form for editing simple objects. The form loads and populates as expected, but the action crashes out, referring to "[Notice] Object of class SS_HTTPRequest could not be converted to int"
In CalendarPage.php:
private static $allowed_actions = array(
'view'
, 'edit'
, 'editForm'
, 'doPostEdit'
, 'doPostDelete'
);
public function edit($request) {
if($entryRecord = DataList::create("CalendarEntry")->byID($this->request->param('ID'))) {
return $this->customise(array(
'Title' => 'Edit: ' . $entryRecord->Title
, 'OneEntry' => $entryRecord
, 'OneEntryForm' => self::editForm($entryRecord->ID)
))->renderWith(array(
'CalendarPage_actions'
, 'CalendarPage'
, 'Page'
));
} else {
// Display a 404 page if user is not allowed this action or the source object cannot be found
return ErrorPage::response_for(404);
}
}
public function editForm($rID) {
$entry = DataList::create("CalendarEntry")->byID($rID);
$fields = new FieldList();
$nField = new HiddenField('ID', 'ID', $rID);
$fields->push($nField);
$tField = new TextField('Title', 'Title', $entry->Title);
$fields->push($tField);
$required = new RequiredFields('Title');
$actions = new FieldList(
new FormAction('doPostEdit', ' Save Changes ')
, new FormAction('doPostDelete', ' Delete Event ')
);
$form = new Form($this, 'editForm', $fields, $actions, $required);
return $form;
}
public function doPostEdit($data, $form, $request) {
$entry = DataList::create("CalendarEntry")->byID($data['ID']);
...
$returnURL = $entry->getEventLink('view');
return $this->redirect($returnURL);
}
Everything works fine so long as I don't try to create an object in the action, then it all ends up in the cactus.
Oddest thing is, other forms almost identical work without issue. Baffled! Ideas?