Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Form - Missing argument 2 - function formAskAction($data, $form)

Go to End

2 Posts   3360 Views


Community Member, 1 Post

21 April 2009 at 4:38am

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 (
			   'Product Name',
			new HiddenField (
			   'Product Id',
			new LiteralField (
				'<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(
				'What type of question is this?',
					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.


Community Member, 712 Posts

23 April 2009 at 10:32am


simple fix, change this line:

return new Form($this, 'formAskAction', new FieldSet( ...


return new Form($this, 'formAsk', new FieldSet( 

The second argument of the Form constructor is the name of the method that returns it, not the action method.