PHP code example of qpdb / html-builder

1. Go to this page and download the library: Download qpdb/html-builder 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/ */

    

qpdb / html-builder example snippets


$jobDeveloperOptions = [
	[
		'2.1' => 'PHP Developer',
		'2.2' => 'C++ Developer',
		'2.3' => 'Java Developer',
		'2.4' => 'JavaScript Developer',
	],
	Html::option()->label( 'Other languages' )->value( '2.9' )
];

$form = Html::form()->encTypeMultipart()->methodPost()
	->withHtmlElement(
		Html::label( 'Full name' )->for( 'full-name' ),
		Html::input()->text()->id( 'full-name' )->name( 'full_name' )->placeholder( 'Your full name' )->value( 'John Doe' ),
		Html::label( 'Your job' )->for( 'job' ),
		Html::select()->id( 'job' )->name('job')->withOptions(
			Html::option()->value( 0 )->label( 'Please select' ),
			Html::option()->value( 1 )->label( 'DevOps' ),
			Html::optgroup()->label('Software developer')->withOptions($jobDeveloperOptions),
			[3 => 'Web design', 4 => 'Game testing']
		)->selectValue( '2.1' ),
		Html::label('Job description')->for('job-description'),
		Html::textarea()->id('job-description')->name('job_description')
	);

Html::div()->withClass( 'class_1', 'class_2' )->id( 'container' )->withHtmlElement( $form )->render();