Hi there,
I am building some front end forms on of which needs to load in the current record based on the url id.
So if the url is: www.example.com/customer/edit/15 i want the form to load in record number 15.
Been struggling with it for days, i know i am close, i just dont know what i am doing wrong. I get the following error:
[Warning] Missing argument 1 for CustomerPage_Controller::CustomerEditForm()
This is what i have so far:
-------------------------------------------------------------------------------------------
<?php
class CustomerPage_Controller extends Page_Controller {
public static $allowed_actions = array (
'CustomerEditForm',
'edit',
);
private static $url_handlers = array(
'//$Action//$ID' => 'edit'
);
//CUSTOMER FORM -> EDIT CUSTOMER
public function CustomerEditForm($request) {
return BootstrapForm::create(
$this,
"CustomerEditForm",
FieldList::create(
TextField::create("Name","Name")
->addExtraClass("required"),
TextField::create("Surname","Surname")
->addExtraClass('required'),
NumericField::create("IDNumber","ID Number")
->setMaxLength('13'),
NumericField::create("Tel1","Phone number 1")
->addExtraClass("required")
->setMaxLength('10')
),
FieldList::create(
FormAction::create("EditCustomer","Edit Customer")
->setStyle("primary"),
FormAction::create("DeleteCustomer","Delete Customer")
->setStyle("warning")
)
->setLayout("horizontal")
->loadDataFrom(CustomerData::get()->byID($rquest->param('ID')))
;
}
// EDIT A CUSTOMER
public static function EditCustomer($data, $form) {
$submission = CustomerData::get()->byID($data["ID"]);
$form->saveInto($submission);
$submission->write();
Controller::curr()->redirectBack();
}
// DELETE A CUSTOMER
public static function DeleteCustomer($data, $form) {
CustomerData::get()->byID($data["ID"])->delete();
Controller::curr()->redirect("home/");
}
}