I'm trying to figure out how the page/action/ID construct works, but the documentation page doesn't exist.
I have a Product Review form in my Product_Controller. In the template the Form Gets automagically Hidden and Revealed with jQuery. However when I add the reCaptcha plug-in all hell breaks loose. I figure the problem is the AJAX call in reCaptcha doesn't like to be called into a HIdden div. So I thought why don't I make the form generation an AJAX call.
Reading the AJAX intro in the REcipes section I understand I need to call DataObjects as pages, and tell the page controller to use a differnrt tempalte for AJAX calls. But I can't get the form to Render in its own Page.
Here is the Form Function if it Helps
class Product_Controller extends Page_Controller {
/**
* Include the product group's requirements, override if the project has the file,
* otherwise use the module one instead
*/
function init(){
Requirements::javascript('jsparty/prototype.js');
Requirements::javascript('jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/behaviour.js');
Requirements::javascript('ecommerce/javascript/Product.js');
//Requirements::themedCSS('Product');
parent::init();
}
/**Create Review Form****
************************
************************/
function UserProductReviewForm() {
// Create fields
$recaptchaField = new RecaptchaField('MyCaptcha');
$recaptchaField->jsOptions = array('theme' => 'white');
$fields = new FieldSet(
new TextField('Name','Name:'),
new EmailField('Email','E-Mail Address:'),
new TextField('Location','Location:'),
new OptionsetField('Rating','Rating',array(
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
)
),
new TextField('Title','Review Title:'),
new TextareaField('Review'),
//$recaptchaField,
new HiddenField('ProductID', '', $this->ID),
new HiddenField('ProductName','',$this->Title)
);
// Create actions
$actions = new FieldSet(
new FormAction('doReview', 'Submit')
);
return new Form($this, 'UserProductReviewForm', $fields, $actions);
}
function doReview($data, $form) {
$review = new Review();
$form->saveInto($review);
$review->write();
}
}
I've commented out the offending reCaptcha element. Shouldn't I be able to load the form with
mysite.com/product-name/UserProductReviewForm