Fields

Want custom Field with your styles and methods ? Custom Field may be generated using the atomic:field Artisan command. By default, all new fields will be placed in the atomic-components/fields directory of your application:

php artisan atomic:field Atomic/CustomField
1

When generating a tool, Artisan will prompt you to update your application's composer.json file. All custom fields are registered with your application as a Composer "path" repository. page name Atomic/CustomField must be like laravel packages name/packagename so you can upload and share it with other developers ♥.

The generated folder in atomic-components/fields/CustomField directory will contain

  • resources/views/field the views for field in contexts (index , create , update , details)
  • src/CustomField.php Field Class
  • src/FieldServiceProvider.php Page Service Provider

CustomField.php

Field main class

class CustomField extends AtomicField
{
    /**
     * The field's view folder.
     *
     * @var string
     */
     public $FieldView = 'Atomic\CustomField-CustomField::field';

}
1
2
3
4
5
6
7
8
9
10

if you want to override any methods for the field or create your own methods.

FieldServiceProvider.php

The main provider for the field to register scripts , styles and views , but the most important part in this file is:

 /**
  * @throws \ReflectionException
  */
    public function boot()
    {
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'Atomic\CustomField-CustomField');
        AtomicPanel::serving(function (ServingAtomic $event) {
            AtomicPanel::serveScripts([]);
            AtomicPanel::serveStyles([]);
        });
    }

1
2
3
4
5
6
7
8
9
10
11
12

you can use those methods

AtomicPanel::serveScripts([]);
AtomicPanel::serveStyles([]);
1
2

to register any styles or scripts for Atomic Panel layout to use in fields

Index.blade.php

This file must have javascript text , with value:

'<h5>'+value+'</h5>'
1
  • you can leave it empty and work with :
public function defaultDisplay()
{
    return parent::defaultDisplay(); // TODO: Change the autogenerated stub
}
1
2
3
4

in CustomField.php file.