Form with dynamic content

Permalink
I'm creating a site where you can sign up for some different courses. You sign up by filling out a form with name/e-mail/address/younameit. However, i would really like to not having the user manually fill out the name of the course (they are just going to mistype something).

A better solution would be to have something like a hidden field which is automatically filled with something like the value of a query-string (e.i. ?course_name=foobar).

I've been googling for solutions but havn't really found any documentation on the subject.

best regards

Peter

 
frz replied on at Permalink Reply
frz
I think in this case we'd make a custom form on the front end (or even a single page if the layout was complex) and add a page to the dashboard under reporting on the backend...
ryan replied on at Permalink Reply
ryan
Here's a link to an introduction to single pages:
http://www.concrete5.org/community/forums/customizing_c5/understand...

The basic concept is that there is the view (single_pages/test.php) and the controller (controllers/test.php)

single_pages/test.php would contain your form, your standard php/html will work. You'd submit the form:
<form action="<?=$this->action('save');?>">

where "save" is the name of the function that does the work in your controller.

controllers/test.php essentially extends the controller class:

<?php
class TestController extends Controller {
// save is called when the form submitted
public function save() {
 $db = Loader::db();
 //$this->post('name'); accessing a post var
 //$this->get('somevar'); accessing a get var
 $db->query(.....);
}
}
?>


Once you create these files, you have to go to the dashboard and add the path:
Dashboard -> Single Pages -> bottom of the page..

add "test"

Then you'll be able to navigate & test your page @ yoursite.com/test

Hope that helps.