PHP code example of joomla / form

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

    

joomla / form example snippets


use Joomla\Form\Form;

use Joomla\Form\Form;

$clientForm = new Form('client');

$customer = new array('first_name'=>'John','last_name'=>'Smith', ...);
$clientForm->bind($customer);

$fields = $customForm->getGroup('');

foreach ($fields as $field) {
	echo $field->label;
	echo $field->input;
}

echo $form->getLabel('first_name');
echo $form->getInput('first_name');

$clientForm->validate($_POST);

$clientForm->getErrors();

namespace Joomla\Form\Field;

class CustomField extends \Joomla\Form\Field
{
	// Override this function
	public function getInput()
	{
		return 'field\'s html string.';
	}
}

namespace Bar\Form\Field;

class FooField extends \Joomla\Form\Field
{
	// Override this function
	public function getInput()
	{
		return 'field\'s html string.';
	}
}

namespace Joomla\Form\Field\Bar;

class FooField extends \Joomla\Form\Field
{
	// Override this function
	public function getInput()
	{
		return 'field\'s html string.'
	}
}