Advance Customization
setLayoutClass
->setLayoutClass('col-md-3'),
You can set layout class to set the component layout length
setHtmlAttributes
->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
->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
->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
->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
->setInputType('hidden'),
setStyle
You can set different input types for your component, such as number, hidden, or checkbox
->setStyle('color:red;'),
setDefaultValue
You can set custom style for your component.
->setDefaultValue('default-value')
Set Help Text
Set help text below a field using the setHelp() method.
->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
->setDisabled(true)
You can set your component disable
setPlaceholder
->setPlaceholder('Product Name')
You can set your component custom placeholder
setReadonly
->setReadonly()
this is for readonly component
setLabel
->setLabel('This is label')
You can set your component label
linkToRoute
ButtonField::init(ButtonField::DELETE)->linkToRoute('products'),
If you need to set custom parameter for linkRoute
, you may use the above callback function.
ButtonField::init(ButtonField::DELETE)->linkToRoute('delete', function ($row) {
return ['id' => $row['id']];
}),
linkToUrl
You may also use linkToUrl() like below
ButtonField::init('Test Button', 'Test')->setHtmlAttributes(['class' => 'mr-2'])
->linkToUrl('this-is-url')
->createAsCrudBoardAction(),
Callback function is also available for this method
ButtonField::init('Test Button', 'Test')->setHtmlAttributes(['class' => 'mr-2'])
->linkToUrl(function (){
return 'this-is-url';
})
->createAsCrudBoardAction(),
displayIf
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.
$this->initCreate()->setTitle("My Create Title");
$this->initEdit($id)->setTitle('Edit Title');
$this->initShow($id, ['full_name', 'msisdn', 'Remarks'])->setTitle("My Show Title");
Set Page Title
Set the page title for the create view.
return view('aim-admin::create')->with('pageTitle', 'My Page Title');
Field Component
Customize the display of specific fields using components.
$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.
<!-- 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:
public function show()
{
return view('your-view')
->injectTop(['css.header'])
->injectBottom(['js.footer']);
}
For the above use case The folder structure should look like the one below.
N.B
That means every injected file should be a Laravel Blade file.
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
return view('home')
->injectTop([
'css.main'
]);
Adding JavaScript
return view('product')
->injectBottom([
'js.jquery'
]);
Combining Top and Bottom Injections
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.