1778 Posts in 581 Topics by 555 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2008 Views |
-
Form - Missing argument 2 - function formAskAction($data, $form)

21 April 2009 at 4:38am
Here are the relevant parts that I'm having trouble with:
When I post the form on the client front end I getfunction 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);
}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.[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 -
Re: Form - Missing argument 2 - function formAskAction($data, $form)

23 April 2009 at 10:32am
Hi,
simple fix, change this line:
return new Form($this, 'formAskAction', new FieldSet( ...
to:
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.
| 2008 Views | ||
|
Page:
1
|
Go to Top |


