This is an outdated version of PHPasap. Please visit http://phpasap.com/docs for the latest version.

Form

PHPasap provides the Form_Builder class to rapidly build forms. The advantage of using this class over raw html code is that this class will take care of prepopulating user filled data in case of validation errors.

Input

To create a input field use the code below

echo Form::text("name", "default_value", ["attr_1"=>"value_1", "attr_2"=>"value_2"]);
//<input type="text" name="name" value="default_value" attr_1="value_1" attr_2="value_2" >

Note that text() method returns string and not echo's it.

If default value defaults to null. If you want to pass a class attribute and don't want a default value you may pass the second attribute as null. Refer the code below.

echo Form::text("name", null, ["placeholder"=>"Name", "class"=>"form-control"]);
//<input type="text" name="name" class="form-control" placeholder="Name" >

Select

echo Form::select("gender", ["male"=>"Male", "female"=>"Female"], "male", ["class"=>"form-control"]);
//male option will be selected by default. Use null to skip