PHP code example of hashbang / waveform

1. Go to this page and download the library: Download hashbang/waveform library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hashbang / waveform example snippets


	class User as CI_Controller {
		function signup() {
			$this->Waveform = new Waveform();

			// Define the Waveform fields
			$this->Waveform->Group('Personal Details');
			$this->Waveform->Define('name');
			$this->Waveform->Define('email')
				->Email();
			$this->Waveform->Define('age')
				->Type('int')
				->Min(18);

			$this->Waveform->Group('Optional Info');
			$this->Waveform->Define('sex')
				->Choice(array('m' => 'Male', 'f' => 'Female'));
			$this->Waveform->Define('music_tastes')
				->Type('text');
			$this->Waveform->Define('avatar')
				->File('temp') // WARNING: This example 

	/**
	* CodeIgniter Car controller
	* Provides a CRUD interface for managing a users cars
	*/
	function Cars() {
		/**
		* Display a list of cars
		*/
		function Index() {
			// Add some listing code here
		}

		/**
		* Edit a car by its ID
		* @param int $carid The Unique ID of the car to edit
		*/
		function Edit($carid = null) {
			$car = $this->Car->GetById($carid); // Assumes you have an appropriate setup that provides a library called `Car` with has a method called `GetById()`

			$this->Waveform = new Waveform(); // Assumes composer or loading the file via 

		$Waveform = new Waveform();
	$Waveform->Group('Personal Details');
	$Waveform->Define('name');
	$Waveform->Define('email')
		->Email();
	$Waveform->Define('age')
		->Type('int')
		->Min(18);
	$Waveform->Group('Optional Info');
	$Waveform->Define('sex')
		->Choice(array('m' => 'Male', 'f' => 'Female'));
	$Waveform->Define('music_tastes')
		->Type('text');
	$Waveform->Define('avatar')
		->File('temp')
		->Max('200kb');

	if ($Waveform->OK()) { // Everything is ok?
		// Everything went ok. $Waveform->Fields is now an array
		// full of the values the user provided.
		echo "<h1>Thanks for signing up {$Waveform->Fields['name']}</h1>";
		echo "<p>Posted values: <pre>" . print_r($_POST, 1) . "</pre></p>";
	} else { // New page OR Something failed
		// Something went wrong OR this is the first time we've viewed the page.
		// Display the form (with errors if any):
		echo "<h1>Signup</h1>";
		echo $Waveform->Form();
	}