PHP Classes

FPHP Fields: Compose and render forms defined programmatically

Recommend this page to a friend!
  Info   View files Example   View files View files (18)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 148 All time: 9,103 This week: 455Up
Version License PHP version Categories
fphp-fields 1.1.1GNU General Publi...5HTML, PHP 5, Libraries
Description 

Author

This package can compose and render forms defined programmatically.

It provides that encapsulate the implementation of forms and different types of form elements.

Currently it provides classes to implement text inputs and their labels, buttons, select inputs, and text areas.

It can also validate input values with support to jQuery validation plugin.

Picture of Leonardo Mauro Pereira Moraes
  Performance   Level  
Name: Leonardo Mauro Pereira ... <contact>
Classes: 3 packages by
Country: Brazil Brazil
Age: 29
All time rank: 2840203 in Brazil Brazil
Week rank: 276 Up27 in Brazil Brazil Up

Example

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="FPHP_Fields">
    <meta name="author" content="Leonardo Mauro">
   
    <title>FPHP_Fields: Simple</title>
   
    <!-- Jquery Validate Includes -->
    <script src="../dist/js/jquery.min.js"></script>
    <script src="../dist/js/validate/jquery.validate.min.js"></script>
    <!-- <script src="../dist/js/validate/jquery.validate-messages-pt-br.js"></script> Brazilian Language -->
    <script src="../dist/js/validate/jquery.validate-auto.js"></script>
</head>

<body>
<?php

/* Autoload Include */
require('../dist/php/autoload.php');

use \
FPHP\Fields\InputField;
use \
FPHP\Fields\BoxesField;
use \
FPHP\Fields\SelectField;
use \
FPHP\Fields\TextareaField;
use \
FPHP\Fields\ButtonField;
use \
FPHP\Fields\FormField;

/**
* Example: Litle example to show some methods
*/

$input = new InputField('text', ['name'=>'full_name', 'validate'=>['required'=>true, 'minlength'=>10]], 'Name');
//$input->construct_field(); //<= echo the 'input' tag
//$input->get_field(); //<= get the 'input' tag

$checkbox = new BoxesField('checkbox', 'boxes', 'Boxes Example');
$checkbox_data = [
    [
'text'=>'abc', 'value'=>0, 'attr'=>['validate'=>['required'=>true]]],
    [
'text'=>'bcd', 'value'=>1]
];
$checkbox->add_boxes($checkbox_data, [1]);
$checkbox->add_box('cde', 2);
//$checkbox->construct_field();

$select = new SelectField(['name'=>'foo', 'id'=>'foo', 'validate'=>['required'=>true, 'min'=>1]], 'Number Select');
$select_data = [
    [
'text'=>'Zero', 'value'=>0],
    [
'text'=>'One', 'value'=>1]
];
$select->add_options($select_data, [0]);
$select->add_option('Two - new', 2);
//$select->construct_field();

$textarea = new TextareaField('Big Text', ['id'=>'textbig', 'name'=>'textbig', 'rows'=>5]);
//$textarea->construct_field();

$button = new ButtonField('submit', 'Send');
//$button->construct_field();

$form = new FormField(['action'=>'#', 'method'=>'get', 'id'=>'form_example', 'name'=>'form_example']);
$fields = [$checkbox, $select, $textarea, $button];
$form->add_field($input);
$form->add_fields($fields);
$form->construct_form();

?>

</body>
</html>


Details

FPHP_Fields

Links: PHP Classes and Github

Simple Online Example and Bootstrap Online Example

Class from package FPHP.

Feature: Have a automatic integration with jquery.validate.js methods for all fields.

___

This class can compose in PHP and render in HTML standard fields forms, like: checkbox, radio, inputs, select, textarea and button. Each field have your specific class, and you can modify and customize with your styles (have an example with Bootstrap). Also include a class with error parser, case you access any class/function using absence or wrong values.

___

/php/
  |__ /fphp/
  |     |__ /fields/
  |            |__ ErrorParserFields.php
  |            |__ FieldInterface.php
  |            |__ MasterFields.php
  |            |__ InputField.php
  |            |__ BoxesField.php
  |            |__ SelectField.php
  |            |__ TextareaField.php
  |            |__ ButtonField.php
  |            |__ FormField.php
  |__ /example/

/js/
  |__ jquery.min.js
  |__ /validate/
        |__ jquery.validate.min.js
        |__ jquery.validate-auto.js
        |__ jquery.validate-messages-pt-br.js

  • /php/fphp/fields/: Classes to render each field and error parser;
  • jquery.validate-auto.js: automatic the validation;
  • jquery.validate-messages-pt-br.js: change the messages to portuguese language;

___

Example

Example: Litle example to show some methods. See others examples in ./example/

require('../dist/php/autoload.php');
use \FPHP\Fields\InputField;
use \FPHP\Fields\FormField;

$input = new InputField('text', array('name'=>'full_name', 'validate'=>['required'=>true, 'minlength'=>10]), 'Name');
//$input->construct_field();	//<= echo the 'input' tag
//$input->get_field();			//<= get the 'input' tag

$form = new FormField(array('action'=>'#', 'method'=>'get', 'name'=>'form_example'));
$form->add_field($input);
$form->construct_form();

___

Also look ~


  Files folder image Files  
File Role Description
Files folder imagedist (2 directories)
Files folder imageexample (2 files)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  dist  
File Role Description
Files folder imagejs (1 file, 1 directory)
Files folder imagephp (1 file, 1 directory)

  Files folder image Files  /  dist  /  js  
File Role Description
Files folder imagevalidate (3 files)
  Accessible without login Plain text file jquery.min.js Data Auxiliary data

  Files folder image Files  /  dist  /  js  /  validate  
File Role Description
  Accessible without login Plain text file jquery.validate-auto.js Data Auxiliary data
  Accessible without login Plain text file jquery.validate-messages-pt-br.js Data Auxiliary data
  Accessible without login Plain text file jquery.validate.min.js Data Auxiliary data

  Files folder image Files  /  dist  /  php  
File Role Description
Files folder imagefphp (1 directory)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files  /  dist  /  php  /  fphp  
File Role Description
Files folder imagefields (9 files)

  Files folder image Files  /  dist  /  php  /  fphp  /  fields  
File Role Description
  Plain text file BoxesField.php Class Class source
  Plain text file ButtonField.php Class Class source
  Plain text file ErrorParserFields.php Class Class source
  Plain text file FieldInterface.php Class Class source
  Plain text file FormField.php Class Class source
  Plain text file InputField.php Class Class source
  Plain text file MasterFields.php Class Class source
  Plain text file SelectField.php Class Class source
  Plain text file TextareaField.php Class Class source

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file index.bootstrap.php Example Example script
  Accessible without login Plain text file index.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:148
This week:0
All time:9,103
This week:455Up