PHP code example of fienta / laravel-translatable-bootforms

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

    

fienta / laravel-translatable-bootforms example snippets


    'providers' => [
        Galahad\BootForms\BootFormsServiceProvider::class,
        Astrotomic\Translatable\TranslatableServiceProvider::class,
        ...
        TypiCMS\LaravelTranslatableBootForms\TranslatableBootFormsServiceProvider::class,
    ],
    

    'aliases' => [
        ...
        'TranslatableBootForm' => Propaganistas\LaravelTranslatableBootForms\Facades\TranslatableBootForm::class,
    ],
    

// View
{!! BootForm::text('Name', 'name')
            ->placeholder('My placeholder') !!}

// Output
<div class="form-group">
    <label for="name">Name</label>
    <input type="text" name="name" class="form-control" placeholder="My Placeholder" />
</div>

// Controller
public function postEdit($request)
{
    $someModel->save($request->all());
}

// View
{!! TranslatableBootForm::text('Name', 'name')
                        ->placeholder('My placeholder') !!}

// Output
<div class="form-group form-group-translation">
    <label for="en[name]">Name (en)</label>
    <input type="text" name="en[name]" class="form-control" placeholder="My Placeholder" data-language="en" />
</div>
<div class="form-group form-group-translation">
    <label for="nl[name]">Name (nl)</label>
    <input type="text" name="nl[name]" class="form-control" placeholder="My Placeholder" data-language="nl" />
</div>

// Controller
public function postEdit($request)
{
    $someModel->save($request->all());
}

{!! TranslatableBootForm::text('Title', 'title')
                        ->attribute('some-attribute', 'Name: %name')
                        ->attribute('another-attribute', 'Locale: %locale') !!}

// Output
<div class="form-group form-group-translation">
    <label for="en[title]">Title (en)</label>
    <input type="text" name="en[title]" class="form-control" some-attribute="Name: en[title]" another-attribute="Locale: en" data-language="en" />
</div>
<div class="form-group form-group-translation">
    <label for="nl[title]">Title (nl)</label>
    <input type="text" name="nl[title]" class="form-control" some-attribute="Name: nl[title]" another-attribute="Locale: nl" data-language="nl" />
</div>

TranslatableBootForm::text('Name','name')
                    ->renderLocale('en')

TranslatableBootForm::text('Name','name')
                    ->dataForLocale('en', 'attributeName', 'attributeValue')
                    ->addClassForLocale(['en', 'nl'], 'addedClass')

TranslatableBootForm::text('Name','item.%locale.name')

// Output
<div class="form-group form-group-translation">
    <label for="item.en.name">Name (en)</label>
    <input type="text" name="item.en.name" class="form-control" data-language="en" />
</div>
bash
    php artisan vendor:publish --provider="TypiCMS\LaravelTranslatableBootForms\TranslatableBootFormsServiceProvider" --tag="config"