-
-
Save netcarver/52c5ba2d64291310a3a2 to your computer and use it in GitHub Desktop.
Example form using public form builder...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once( $_SERVER['DOCUMENT_ROOT'] . "/site/forms/forms.php" ); | |
$f = Form('Contact', './') | |
->setRenderer( fxForm::BASIC ) // Choose the renderer to use to convert this to HTML(5) | |
// I also plan to implement a renderer for twitter's bootstrap and other renderers can | |
// be plugged in as needed. | |
->onSuccess('MySuccessHandler') // Which routine gets called on successful submission and validation? | |
->add( Fieldset('About you...') | |
->add( Input('name', 'Your name')->required() ) // Creates a text input with client + server validation | |
->add( Email('email', 'Your email address')->required() ) // Creates an email input with client + server validation | |
->add( URL('url', 'Your Website') ) // Same here but for a url | |
) | |
->add( Fieldset('Your message...') | |
->add( Textarea('msg', 'Your message to us')->required()->maxlength(1000) ) | |
) | |
->add( Fieldset('Legal stuff...') | |
->add( Checkbox('cond', '>I Agree to the terms and conditions.' ) ) // Creates a checkbox with a right-aligned label | |
) | |
->add( Submit('Send')->enabledIf('cond.checked') ) // Submit button state is controlled by the checkbox state (client side) | |
// Of course, on the server side, validation of elements will still take place. | |
// enabledIf() also allows you to check form element values. | |
// eg: ->enabledIf('age.value<18') | |
->process() | |
; | |
echo $f; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment