Here are the relevant parts that I'm having trouble with:
function formAsk()
{
return new Form($this, 'formAskAction', new FieldSet(
// List your fields here
new HiddenField (
'ProductName',
'Product Name',
$this->Title
),
new HiddenField (
'ProductId',
'Product Id',
$this->InternalProductId
),
new LiteralField (
'Explanation',
'<p><b>Ask us a question about this product</b></p>
<p>Please select the type of question you would like to ask and fill in the boxes below.</p>'
),
new OptionsetField(
'Who',
'What type of question is this?',
array(
self::FORM_WHO_SALES => 'Sales',
self::FORM_WHO_TECH => 'Technical Support'
)
),
new TextField('FirstName', 'First name'),
new TextField('Surname'),
new EmailField('Email'),
new PhoneNumberField('Telephone', 'Telephone', 0),
new TextareaField('Enquiry')
), new FieldSet(
// List the action buttons here
new FormAction('formAskAction', 'Submit')
), new RequiredFields(
'Who', 'FirstName', 'Surname', 'Email', 'Enquiry'
));
}
function formAskAction($data, $form)
{
//Director::redirect($this->Link() . 'formAskDone?referrer=' . urlencode($data['Referrer']));
$data = array('formAsk' => 'Thank you for your email! '.$this->form_who[intval($form->Who)]);
return $this->customise($data);
}
When I post the form on the client front end I get [Warning] Missing argument 2 for Product_Controller::formAskAction(), called in /var/www/sapphire/core/control/Controller.php on line 162 and defined
POST /new-product/formAskAction
Now to my knowledge I've not updated my silverstripe version, and all that's changed from my working version was that I deleted the database on my development machine and then did a reinstall.