2017 © Pedro Peláez
 

library html

HTML Component for Orchestra Platform

image

orchestra/html

HTML Component for Orchestra Platform

  • Saturday, July 28, 2018
  • by crynobone
  • Repository
  • 4 Watchers
  • 23 Stars
  • 63,350 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 8 Forks
  • 4 Open issues
  • 68 Versions
  • 3 % Grown

The README.md

HTML Component for Orchestra Platform

HTML Component extends the functionality of Illuminate\Html with the extra functionality to including a chainable Form and Table builder. These set of functionality are the backbone in allowing extensions in Orchestra Platform to attach action to any existing form or table., (*1)

tests Latest Stable Version Total Downloads Latest Unstable Version License Coverage Status, (*2)

Version Compatibility

Laravel HTML
5.5.x 3.5.x
5.6.x 3.6.x
5.7.x 3.7.x
5.8.x 3.8.x
6.x 4.x
7.x 5.x
8.x 6.x

Installation

To install through composer, run the following command from terminal:, (*3)

composer require "orchestra/html"

Configuration

Next add the service provider in config/app.php., (*4)

'providers' => [

    // ...

    Orchestra\Html\HtmlServiceProvider::class,
],

Aliases

You might want to add the following to class aliases in config/app.php:, (*5)

'aliases' => [

    // ...

    'Form' => Orchestra\Support\Facades\Form::class,
    'HTML' => Orchestra\Support\Facades\HTML::class,
    'Table' => Orchestra\Support\Facades\Table::class,
],

Usage

Orchestra\Html\HtmlBuilder is a small improvement from Illuminate\Html\HtmlBuilder., (*6)

Advise to use this only when manipulating HTML outside of view, otherwise it's better (and faster) to use html., (*7)

Create HTML

Create a HTML tag from within your libraries/extension using following code:, (*8)

return HTML::create('p', 'Some awesome information');

Will return <p>Some awesome information</p>., (*9)

You can customize the HTML attibutes by adding third parameter., (*10)

return HTML::create('p', 'Another awesomeness', ['id' => 'foo']);

Will return <p id="foo">Another awesomeness</p>., (*11)

Raw HTML Entities

Mark a string to be excluded from being escaped., (*12)

return HTML::link('foo', HTML::raw('<img src="foo.jpg">'));

Will return <a href="foo"><img src="foo.jpg"></a>., (*13)

This also can be dynamically done via., (*14)

return HTML::link('foo', HTML::image('foo.jpg'));

Decorate HTML

Decorate method allow developer to define HTML attributes collection as HTML::attributes method, with the addition of including default attributes array as second parameter., (*15)

return HTML::decorate(['class' => 'foo'], ['id' => 'foo', 'class' => 'span5']);

Will return array('class' => 'foo span5', 'id' => 'foo');., (*16)

It also support replacement of default attributes if such requirement is needed., (*17)

return HTML::decorate(['class' => 'foo !span5'], ['class' => 'bar span5']);

Will return array('class' => 'foo bar');, note that span5 is excluded when we give !span5 in the first parameter., (*18)

Forms

Creating forms couldn't be any easier using Orchestra's HTML package. Let's get started., (*19)

Creating a new Form

To create a new form, use the Form::of() method. The first parameter is simply a string to define what the form is for:, (*20)

return Form::of('users');
Form Attributes

To customize your forms attributes, call the attributes($attributes) method on the FormGrid instance:, (*21)

return Form::of('users', function ($form) {
    $attributes = [
        'method' => 'PATCH',
        'id'     => 'user-login-form',
        'class'  => 'form-horizontal',
    ];

    $form->attributes($attributes);
});
Specifying the Form layout

To specify the layout of the form, call the layout($view) method on the FormGrid instance:, (*22)

return Form::of('users', function ($form) {
    $form->layout('layouts.form');
});
Adding Fields

To add fields to our form, we'll pass in a closure into the second parameter, and call the fieldset() method off of the injected FormGrid. Here's an example:, (*23)

return Form::of('users', function ($form) {
    $form->fieldset(function ($fieldset) {
        $fieldset->control('input:text', 'username');
        $fieldset->control('input:email', 'email');
        $fieldset->control('input:password', 'password');
    });
});
Available Fields
// A text field
$form->control('input:text', 'name');

// A password field
$form->control('input:password', 'name');

// A file field
$fieldset->control('input:file', 'name');

// A textarea filed
$form->control('textarea', 'name');

// A select field
$form->control('select', 'name')
    ->options(['one', 'two', 'three']);
Adding Labels to Fields

To add a label onto a form control, use the method label():, (*24)

$form->fieldset(function ($fieldset) {
    $form->control('input:text', 'username')
        ->label('Username');

    $form->control('input:email', 'email')
        ->label('Email');

    $form->control('input:password', 'password')
        ->label('Password');
});
Adding Default Values to Fields

To add a default value to the field, use the method value() on the form control:, (*25)

$form->fieldset(function ($fieldset) {
    $form->control('input:text', 'username')
        ->label('Username')
        ->value(Auth::user()->username);

    $form->control('input:email', 'email')
        ->label('Email')
        ->value(Auth::user()->email);

    $form->control('input:password', 'password')
        ->label('Password');
});
Changing the submit button label

To change the submit button label, modify the FormGrid property submit like so:, (*26)

return Form::of('users', function ($form) {
    // The form submit button label
    $form->submit = 'Save';

    $form->fieldset(function ($fieldset) {
        $form->control('input:text', 'username');
        $form->control('input:email', 'email');
        $form->control('input:password', 'password');
    });
});
Customizing the form control attributes

To customize the form controls attributes, call the attributes($attributes) method on the control:, (*27)

$attributes = [
    'placeholder' => 'Enter your username',
    'class'       => 'form-control',
];

$form->control('input:text', 'username')
    ->attributes($attributes);
Customizing the form control itself
$form->control('input:email', 'email', function ($control) {
    $control->field(function ($row) {
        return "<input type='email' name="email" value='$row->email'>";
    });
});

You could also create a Renderable class:, (*28)

use Illuminate\Contracts\Support\Renderable;

class EmailAddressField implements Renderable
{
    public function __construct($name, $value)
    {
        $this->name = $name;
        $this->value = $value;
    }

    public function render()
    {
        return sprintf('<input type="email" name="%s" value="%s">', $this->name, $this->value);
    }
}

And you can simply register it via:, (*29)

$form->control('input:email', 'email', function ($control) {
    $control->field(function ($row) {
        return new EmailAddressField('email', $row->email);
    });
});
Displaying your form

To display your form, simply display it in your view with unescaped blade tags:, (*30)

public function index()
{
    $form = Form::of('users', function ($form) {
        $form->fieldset(function ($fieldset) {
            $form->control('input:text', 'username');
            $form->control('input:email', 'email');
            $form->control('input:password', 'password');
        });
    });

    return view('index', compact('form'));
}
// In index.blade.php

{!! $form !!}

The Versions

28/07 2018

3.6.x-dev

3.6.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

07/07 2018
14/10 2017

3.5.x-dev

3.5.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

12/03 2017

3.4.x-dev

3.4.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

26/12 2016

3.3.x-dev

3.3.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

03/12 2016

v3.3.2

3.3.2.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/06 2016

v3.3.1

3.3.1.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/06 2016

3.2.x-dev

3.2.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/06 2016

v3.2.4

3.2.4.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/06 2016

3.1.x-dev

3.1.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/06 2016

v3.1.18

3.1.18.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

15/06 2016

v3.3.0

3.3.0.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

31/01 2016

v3.2.3

3.2.3.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

06/01 2016

v3.2.2

3.2.2.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

06/01 2016

v3.1.17

3.1.17.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

30/12 2015

v3.2.1

3.2.1.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

30/12 2015

v3.1.16

3.1.16.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

22/12 2015

v3.2.0

3.2.0.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

22/12 2015

v3.1.15

3.1.15.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

18/12 2015

v3.1.14

3.1.14.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

01/12 2015

v3.1.13

3.1.13.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

24/11 2015

v3.1.12

3.1.12.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

29/10 2015
28/10 2015
03/10 2015
22/09 2015
19/09 2015
14/09 2015
14/09 2015

3.0.x-dev

3.0.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

14/09 2015

v3.0.2

3.0.2.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

08/08 2015
06/07 2015
16/06 2015
03/06 2015
24/05 2015
07/05 2015

v3.0.1

3.0.1.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

05/02 2015

v3.0.0

3.0.0.0 http://orchestraplatform.com/docs/latest/components/html/

HTML Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

13/07 2014

2.0.x-dev

2.0.9999999.9999999-dev http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

13/07 2014

v2.0.11

2.0.11.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel form html table orchestral orchestra-platform

26/11 2013

v2.0.10

2.0.10.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

21/10 2013

v2.0.9

2.0.9.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

16/10 2013

v2.0.8

2.0.8.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

01/10 2013

v2.0.7

2.0.7.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

27/09 2013

v2.0.6

2.0.6.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

27/07 2013

v2.0.5

2.0.5.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

19/07 2013

v2.0.4

2.0.4.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

09/07 2013

v2.0.3

2.0.3.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

02/07 2013

v2.0.2

2.0.2.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

30/06 2013

v2.0.1

2.0.1.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform

19/06 2013

v2.0.0

2.0.0.0 http://orchestraplatform.com/docs/2.0/components/html/

Orchestra Platform 2 Html Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel orchestral orchestra-platform