PHP code example of typicms / laravel-translatable-bootforms

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

    

typicms / laravel-translatable-bootforms example snippets


   'aliases' => [
       ...
       'TranslatableBootForm' => TypiCMS\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="name[en]">Name (en)</label>
    <input type="text" name="name[en]" class="form-control" placeholder="My Placeholder" data-language="en">
</div>
<div class="form-group form-group-translation">
    <label for="name[nl]">Name (nl)</label>
    <input type="text" name="name[nl]" 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="title[en]">Title (en)</label>
    <input type="text" name="title[en]" class="form-control" some-attribute="Name: title[en]" another-attribute="Locale: en" data-language="en">
</div>
<div class="form-group form-group-translation">
    <label for="title[nl]">Title (nl)</label>
    <input type="text" name="title[nl]" class="form-control" some-attribute="Name: title[nl]" 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')
bash
   php artisan vendor:publish --provider="TypiCMS\LaravelTranslatableBootForms\TranslatableBootFormsServiceProvider" --tag="config"