Forms, simplified v3


The Challenge

The Files

The Changes

The Examples

In Conclusion

The License

Share on Facebook!


The challenge

Programming HTML forms in PHP with emails, urls, checkboxes, selects, textareas, and validation is a time consuming process. This system makes it easy - with examples! I use this tiny library because:


The Files

Grab the files here: forms-3.zip


Changes


Examples

Output from submitting forms will appear here:

Array
(
)

Example 1: Basic usage

form_start();
form_text('name');
form_submit();
form_end();

Example 2: Into the deep end.

form_start('#examples','post','test_form','edit_form confirm_unload');  // edit form gives it some style
form_text('name','Your Name','','I set .required .input_title to be bold.
I set .invalid .input_title to be red.','required'); form_password('password','Your Pass','','Hint: If I was going to sleigh citizen kane...'); form_email('email','Your Email','','We won\'t save any of these. It\'s just a demo.','required'); form_hidden('hidden_value','Yo momma'); form_static('Note','I hid a value in the code just above this line.','It\'s true, he did.'); form_url('url','Your URL','invalid URL','don\'t forget the http:// part!'); form_textarea('textarea','Your Comment'); form_checkbox('checkbox','Check this:','','I rarely read the terms of service.','required'); $arr=array(''=>'','1'=>'Puppies','2'=>'Death Metal','3'=>'Videos of people operating on themselves','4'=>'Babies'); form_date('date','When?', array('min'=>date('Y-m-d'), 'max'=>date('Y-m-d', strtotime('+1 month'))), date('Y-m-d', strtotime('+1 week')), 'test','required'); form_select('choice','Favorite:',$arr,0,'The rest will all be shipped to North Korea.','required'); form_cancel('cancel','No, No, No!','Do not click me'); form_submit('submit','Oh, YEAH!','Click me, I love it!','Have you double checked everything?'); form_end();
I set .required .input_title to be bold.
I set .invalid .input_title to be red.
Hint: If I was going to sleigh citizen kane...
I hid a value in the code just above this line.
It's true, he did.
don't forget the http:// part!
I rarely read the terms of service.
The rest will all be shipped to North Korea.
test
Have you double checked everything?

In conclusion

Please read the forms.php, form_block.php, forms.js, and forms.css files for more details.

If you have anything to contribute to the library, please feel free to send it and I will add it in.

I don't expect anything for this but feedback, donations, and offers of work are always welcome. ;)

Thanks!


Creative Commons License
Forms, simplified by Dan Royer is licensed under a Creative Commons Attribution-Share Alike 2.5 Canada License.
Based on a work at www.marginallyclever.com.
Permissions beyond the scope of this license may be available at http://www.marginallyclever.com/forms/.

Share on Facebook with your web-savvy droogs

Page © Marginally Clever Software