Skip to content

Advance Customization

setLayoutClass

php
  ->setLayoutClass('col-md-3'),

You can set layout class to set the component layout length

setHtmlAttributes

php
  ->setHtmlAttributes(['id' => 'product-id']),

You can set any Html Attribute of a component

This option is available for the following component

ChainSelectField|ChoiceField|DateTimeField|FileField|FormFieldTrait|HiddenField|IdField|InputField|TextareaField|TextField

setCssClass

php
->setCssClass('new-class'),

To assign a new CSS class to a form field, removing any previously assigned classes, use the setCssClass method:

This option is available for the following component

ChainSelectField|ChoiceField|DateTimeField|FileField|FormFieldTrait|HiddenField|IdField|InputField|TextareaField|TextField

addCssClass

php
->addCssClass('custom-class'),

To add a CSS class to a form field, use the addCssClass method:

This option is available for the following component

ChainSelectField|ChoiceField|DateTimeField|FileField|FormFieldTrait|HiddenField|IdField|InputField|TextareaField|TextField

removeCssClass

php
->removeCssClass('class-name'),

To remove a CSS class from a form field, use the removeCssClass method:

This option is available for the following component

ChainSelectField|ChoiceField|DateTimeField|FileField|FormFieldTrait|HiddenField|IdField|InputField|TextareaField|TextField

setInputType

php
->setInputType('hidden'),

setStyle

You can set different input types for your component, such as number, hidden, or checkbox

php
->setStyle('color:red;'),

setDefaultValue

You can set custom style for your component.

php
->setDefaultValue('default-value')

Set Help Text

Set help text below a field using the setHelp() method.

php
->setHelp('<b>This is Help Text</b>');

This will display the specified help text below the field.

setDisabled

You can set a default value for your component

php
->setDisabled(true)

You can set your component disable

setPlaceholder

php
->setPlaceholder('Product Name')

You can set your component custom placeholder

setReadonly

php
->setReadonly()

this is for readonly component

setLabel

php
->setLabel('This is label')

You can set your component label

linkToRoute

php
ButtonField::init(ButtonField::DELETE)->linkToRoute('products'),

If you need to set custom parameter for linkRoute, you may use the above callback function.

php
ButtonField::init(ButtonField::DELETE)->linkToRoute('delete', function ($row) {
    return ['id' => $row['id']];
}),

linkToUrl

You may also use linkToUrl() like below

php
ButtonField::init('Test Button', 'Test')->setHtmlAttributes(['class' => 'mr-2'])
  ->linkToUrl('this-is-url')
  ->createAsCrudBoardAction(),

Callback function is also available for this method

php
ButtonField::init('Test Button', 'Test')->setHtmlAttributes(['class' => 'mr-2'])
    ->linkToUrl(function (){
        return 'this-is-url';
    })
    ->createAsCrudBoardAction(),

displayIf

php
ButtonField::init(ButtonField::DELETE)->linkToRoute('delete', function ($row) {
    return ['id' => $row['id'],'pid'=>$row['parent_id']];
})->displayIf(function($row){
    return $row['created_by'] == 2
});

You can controll the visibility of a component using the displayIf callback function.

Set Title

Set a custom title for the create page using the setTitle method.

php
$this->initCreate()->setTitle("My Create Title");
php
$this->initEdit($id)->setTitle('Edit Title');
php
$this->initShow($id, ['full_name', 'msisdn', 'Remarks'])->setTitle("My Show Title");

Set Page Title

Set the page title for the create view.

php
return view('aim-admin::create')->with('pageTitle', 'My Page Title');

Field Component

Customize the display of specific fields using components.

php
$this->initShow($id, [
    Field::init('full_name', 'Name')->setComponent('full_name'),
    'msisdn'
]);
return view('aim-admin::show', ['pageTitle' => 'My show page title']);

Example of full_name.blade.php Component:

In the component view, you can access the $value variable and the $row variable.

blade
<!-- resources/views/components/full_name.blade.php -->
{{$value}}

This customization guide demonstrates how to set custom titles and use custom components for creating, editing, and showing records in your application.

View Injection

This custom Laravel feature allows you to dynamically inject content at the top and bottom of your views. It's particularly useful for adding CSS, JavaScript, meta tags, or any other content that needs to be placed at specific locations in your HTML structure.

Usage

In Controllers

You can use the injectTop and injectBottom methods when returning a view from your controller:

php
public function show()
{
    return view('your-view')
        ->injectTop(['css.header', 'meta.tags'])
        ->injectBottom(['js.footer', 'js.analytics']);
}

Methods

injectTop($files)

Injects content at the top of the view, typically in the <head> section.

  • $files: An array of view names or a single view name to be rendered and injected.

injectBottom($files)

Injects content at the bottom of the view, typically just before the closing </body> tag.

  • $files: An array of view names or a single view name to be rendered and injected.

Examples

Adding CSS and Meta Tags

php
return view('home')
    ->injectTop([
        'css.main',
        'meta.seo'
    ]);

Adding JavaScript

php
return view('product')
    ->injectBottom([
        'js.jquery',
        'js.product-gallery'
    ]);

Combining Top and Bottom Injections

php
return view('dashboard')
    ->injectTop(['css.dashboard', 'meta.dashboard'])
    ->injectBottom(['js.charts', 'js.dashboard-widgets']);

Notes

  • If a specified view file is not found, a warning will be logged, but the application will continue to process other files.
  • You can inject multiple files in a single call by passing an array.
  • The content is rendered before injection, so you can use Blade syntax in your injected views.

Developed By ❤️ Taki Elias