PHP code example of flextype-components / form

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

    

flextype-components / form example snippets


use Flextype\Component\Form\Form;

// Registering a Form macro
Form::macro('my_field', function() {
    return '<input type="text" name="my_field">';
});

// Calling a custom Form macro
echo Form::my_field();


// Registering a Form macro with parameters
Form::macro('my_field', function($value = '') {
    return '<input type="text" name="my_field" value="'.$value.'">';
});

// Calling a custom Form macro with parameters
echo Form::my_field('Flextype');

// Form will submit back to the current page using POST
echo Form::open();

// Form will submit to 'search' using GET
echo Form::open('search', array('method' => 'get'));

// When "file" inputs are present, you must 

echo Form::input('username', $username);

echo Form::hidden('user_id', $user_id);

echo Form::password('password');

echo Form::file('image');

echo Form::checkbox('i_am_not_a_robot');

echo Form::radio('i_am_not_a_robot');

echo Form::textarea('text', $text);

echo Form::select('themes', array('default', 'classic', 'modern'));

echo Form::submit('save', 'Save');

echo Form::button('save', 'Save Profile', array('type' => 'submit'));

echo Form::label('username', 'Username');

echo Form::close();