PHP code example of lucasnribeiro / form-forge
1. Go to this page and download the library: Download lucasnribeiro/form-forge 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/ */
lucasnribeiro / form-forge example snippets
use Lucasnribeiro\FormForge\Form;
use Lucasnribeiro\FormForge\Inputs\InputFactory;
$form = new Form(new InputFactory());
$form->setMethod('post')
->setAction('/submit-form')
->addField('name', 'text', ['label' => 'Your Name'])
->addField('email', 'email', ['label' => 'Your Email'])
->addField('country', 'select', [
'label' => 'Country',
'options' => ['US' => 'United States', 'CA' => 'Canada', 'UK' => 'United Kingdom']
])
->submitButton()
->setValue('Send')
->addClass('btn-primary');
echo $form->render();
$form->addField('email', 'email', ['label' => 'Your Email'])
->field('email')
->addClass('form-control')
->label()
->addClass('form-label');
$form->submitButton()
->setValue('Send Message')
->addClass('btn')
->addClass('btn-primary')
->addAttribute('id', 'contact-submit');
Lucasnribeiro\FormForge\FormBuilder;
$form = FormBuilder::create();
$form->setMethod('post')
->setAction('/submit-contact')
->addField('name', 'text', ['label' => 'Full Name'])
->addField('email', 'email', ['label' => 'Email Address'])
->addField('subject', 'text', ['label' => 'Subject'])
->addField('message', 'textarea', ['label' => 'Your Message']);
$form->field('name')
->addClass('mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50')
->label()
->addClass('block text-sm font-medium text-gray-700');
$form->field('email')
->addClass('mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50')
->label()
->addClass('block text-sm font-medium text-gray-700');
$form->field('subject')
->addClass('mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50')
->label()
->addClass('block text-sm font-medium text-gray-700');
$form->field('message')
->addClass('mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50')
->label()
->addClass('block text-sm font-medium text-gray-700');
$form->submitButton()
->setValue('Send Message')
->addClass('mt-4 px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500');