Last active
February 2, 2017 23:31
-
-
Save AskingQuestions/8997435d5c180cda27d4149e320c8e43 to your computer and use it in GitHub Desktop.
Example of a form in websom
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 | |
$form = new Form("MyFormName"); //Create the form | |
$text = new Text();//Create the text input | |
$text->max_characters = 10; //Set the max number of chars allowed to 10 | |
$text->blank = false; //Do not allow blank input | |
$text->placeholder = "Example text box"; | |
$form->addInput("textName", $text); //Add the text input above and use textName to reference it. | |
$form->structure = new Structure("%textName%".Theme::input_submit("Submit to server", "")->get()); //Set the html structure. | |
$form->on("success", function ($inputData) { //Listen for the form success(submited and sanatized) event. | |
Wait(2); //Wait 2 seconds before sending. | |
$message = new Message(); //Create a new message for sending. | |
$message->add("form", | |
Message::Success("Your input was ".$inputData["textName"])); //Add the success message to the form element. | |
return $message; //Send message to client | |
}); | |
$form->check(); //Check if the form has been submited. | |
echo $form->get(); //Render the form. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment