Hi b0bro,
The 'right' way to create forms in SS is in your page controller, don't do it in the template.
Step 1, create the form in your page controller
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); (don't forget to call jquery, I'm using SS 2.4, we will need to change the path)
Requirements::javascript("themes/blackcandy/javascript/coolform.js"); my js
function CoolForm() {
$fields = new FieldSet(
new TextField('yourName', 'Your Name:')
);
$actions = new FieldSet(
new FormAction('MyName', 'name') //maybe you will nedd to create a dummy function 'MyName', it wont do anything tho
);
$form = new Form($this, 'CoolForm', $fields, $actions);
$form->forAjaxTemplate();
return $form;
}
step 2. create the js
(function($) {
$(document).ready(function() {
$("#Form_CoolForm").submit(function(){
$('#result').load('CoolController', {values: $(this).serialize()});
return false;
});
});
})(jQuery);
step 3 create the controller to get receive values from the JS and display them in the page
class CoolController extends Controller {
function index(){
Debug::dump($this->requestParams);
echo $this->requestParams['values'];
}
}
and last step, create the div in your page template <div id="result"></div>