PHP code example of rootcstar / form-builder

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

    

rootcstar / form-builder example snippets


use RootCStar\FormBuilder\Forms\FormBuilder;

$form = FormBuilder::create()
    ->formId('my-form')
    ->apiUrl('/api/endpoint')      // API endpoint for form submission
    ->proxyUrl('/proxy/endpoint')  // Optional proxy URL (defaults to apiUrl if not set)
    ->redirectUrl('/success')      // Optional redirect URL after submission
    ->apiMethod('POST')           // HTTP method (defaults to POST)
    ->title('Form Title')         // Optional form title
    ->subtitle('Form Subtitle');  // Optional form subtitle

$form->textField('name', 'Full Name')
    ->value('John Doe');

$form->numberField('age', 'Age')
    ->ue(25);

$form->hiddenField('user_id', '')
    ->value(1);

$form->customFieldHtml('<div class="alert alert-info">Custom HTML</div>', 'Optional Label');

// Single File Upload
$form->fileField('document', 'Upload File')
    ->);

// Multiple File Upload
$form->fileField('photos', 'Upload Images')
    ->

// Basic Select
$form->selectField('country', 'Select Country')
    ->ted Kingdom'
    ])
    ->selected('us');

// Multiple Select
$form->selectField('skills', 'Select Skills')
    ->

// Single Select2
$form->select2Field('category', 'Select Category')
    ->)
    ->selected(1);

// Multiple Select2
$form->select2Field('tags', 'Select Tags')
    ->

$form->emailField('email', 'Email Address')
    ->

$form->passwordField('password', 'Password')
    ->

$form->telephoneField('phone', 'Phone Number')
    ->

$form->textAreaField('description', 'Description')
    ->

$form->datePickerField('birth_date', 'Birth Date')
    ->24-01-01');

$form->checkboxField('terms', 'Terms and Conditions')
    ->        'newsletter' => 'Subscribe to newsletter'
    ])
    ->multiple()
    ->inline();

$form->submitButton('Save Changes', 'btn-primary');

return view('your.view', [
    'form' => $form->render()
]);

{!! $form !!}