PHP code example of insitaction / easyadmin-fields-bundle

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

    

insitaction / easyadmin-fields-bundle example snippets


// DashboardController.php

use Insitaction\EasyAdminFieldsBundle\EasyAdminFieldsBundle;

public function configureAssets(): Assets
{
    $assets = parent::configureAssets();
    
    return EasyAdminFieldsBundle::configureAssets($assets);
}

// DashboardController.php

use Insitaction\EasyAdminFieldsBundle\Asset\AssetPackage;

public function configureAssets(): Assets
{
    $jsAsset = Asset::new('app.js')->package(AssetPackage::PACKAGE_NAME);
    $cssAsset = Asset::new('app.css')->package(AssetPackage::PACKAGE_NAME);

    return parent::configureAssets()
        ->addJsFile($jsAsset)
        ->addCssFile($cssAsset);
}

MaskField::adapt(
    BooleanField::new('hasAuthor'),
    [
        "true" => ['author']
    ]
)

BooleanField::new('hasAuthor')
    ->setFormTypeOptions([ 
        'row_attr' => [
            'data-controller' => 'mask-field',
            'data-mask-field-map' => MaskField::encodeMap([
                "true" => ['author']
            ])
        ],
    ])

[
    "true" => ['author']
]

[
    "A" => ['field1'],
    "B" => ['field1', 'field2'],
    "C" => ['field2'],
]

 DependentField::adapt(
    AssociationField::new('author'),
    [
        'callback_url' => $this->urlGenerator->generate('authors', [], UrlGeneratorInterface::ABSOLUTE_URL),
        'dependencies' => ['gender'],
        'fetch_on_init' => true
    ]
)

'dependencies' => ['gender']