Skip to content

Commit 10618e1

Browse files
docs for select2 from array tagging option(#641)
1 parent dd1d84e commit 10618e1

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

7.x/crud-fields.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ CRUD::field([ // Checklist
325325
'pivot' => true,
326326
'show_select_all' => true, // default false
327327
// 'number_of_columns' => 3,
328-
328+
329329
]);
330330
```
331331

@@ -874,7 +874,7 @@ CRUD::field([
874874
875875
#### Uploading files with summernote
876876

877-
Summernote saves images as base64 encoded strings in the database. If you want to save them as files on the server, you can use the [Summernote Uploader](https://backpackforlaravel.com/docs/7.x/crud-uploaders). Please note that the Summernote Uploader is part of the `backpack/pro` package.
877+
Summernote saves images as base64 encoded strings in the database. If you want to save them as files on the server, you can use the [Summernote Uploader](https://backpackforlaravel.com/docs/7.x/crud-uploaders). Please note that the Summernote Uploader is part of the `backpack/pro` package.
878878
Input preview:
879879

880880
![CRUD Field - summernote](https://backpackforlaravel.com/uploads/docs-4-2/fields/summernote.png)
@@ -1153,22 +1153,22 @@ CRUD::field([ // Address google
11531153
]);
11541154
```
11551155

1156-
Using Google Places API is dependent on using an API Key. Please [get an API key](https://console.cloud.google.com/apis/credentials) - you do have to configure billing, but you qualify for $200/mo free usage, which covers most use cases. Then copy-paste that key as your ```services.google_places.key``` value.
1156+
Using Google Places API is dependent on using an API Key. Please [get an API key](https://console.cloud.google.com/apis/credentials) - you do have to configure billing, but you qualify for $200/mo free usage, which covers most use cases. Then copy-paste that key as your ```services.google_places.key``` value.
11571157

11581158
**IMPORTANT NOTE**: Your key needs access to the following APIS:
11591159
- Maps JavaScript API;
11601160
- Places API;
11611161
- Geocoding API.
11621162

1163-
While developing you can use an "unrestricted key" (no restrictions for where the key is used), but for production you should use a separate key, and **MAKE SURE** you restrict the usage of that key to your own domain.
1163+
While developing you can use an "unrestricted key" (no restrictions for where the key is used), but for production you should use a separate key, and **MAKE SURE** you restrict the usage of that key to your own domain.
11641164

11651165
So inside your ```config/services.php``` please add the items below:
11661166
```php
11671167
'google_places' => [
11681168
'key' => 'the-key-you-got-from-google-places'
11691169
],
11701170
```
1171-
Alternatively you can set the key in your field definition, but we do **not recommend** it:
1171+
Alternatively you can set the key in your field definition, but we do **not recommend** it:
11721172
```php
11731173
[
11741174
'name' => 'google_field',
@@ -1445,7 +1445,7 @@ Using Google Places API is dependent on using an API Key. Please [get an API key
14451445
- Places API;
14461446
- Geocoding API.
14471447

1448-
While developing you can use an "unrestricted key" (no restrictions for where the key is used), but for production you should use a separate key, and **MAKE SURE** you restrict the usage of that key to your own domain.
1448+
While developing you can use an "unrestricted key" (no restrictions for where the key is used), but for production you should use a separate key, and **MAKE SURE** you restrict the usage of that key to your own domain.
14491449

14501450
**How to save in multiple inputs?**
14511451

@@ -1791,7 +1791,7 @@ CRUD::field([
17911791

17921792
By default Backpack does not allow you to select the same pivot twice. If you want to allow the selection of the same pivot more than once you should take some setup steps before. Follow along with the steps below:
17931793

1794-
**1)** Make sure your pivot table has a unique key, usually an auto-increment id. If you don't have one, you can add it with a migration.
1794+
**1)** Make sure your pivot table has a unique key, usually an auto-increment id. If you don't have one, you can add it with a migration.
17951795

17961796
**2)** Add the `id` to your `->withPivot()` fields on your relation. Eg:
17971797
```php
@@ -1816,7 +1816,7 @@ CRUD::field([
18161816
'name' => 'companies',
18171817
'type' => 'relationship',
18181818
'allow_duplicate_pivots' => true,
1819-
'subfields' => // your subfields (do not add `id` as a subfield. That's done automatically by Backpack).
1819+
'subfields' => // your subfields (do not add `id` as a subfield. That's done automatically by Backpack).
18201820
]);
18211821
```
18221822

@@ -2180,7 +2180,8 @@ CRUD::field([ // select2_from_array
21802180
'allows_null' => false,
21812181
'default' => 'one',
21822182
// 'allows_multiple' => true, // OPTIONAL; needs you to cast this to array in your model;
2183-
// 'sortable' => true, // requires the field to accept multiple values, and allow the selected options to be sorted.
2183+
// 'sortable' => true, // requires the field to accept multiple values, and allow the selected options to be sorted;
2184+
// 'tagging' => true, // allow users to type and create new options.
21842185
]);
21852186
```
21862187

@@ -2368,7 +2369,7 @@ CRUD::field([
23682369
'minimum_input_length' => 2, // minimum characters to type before querying results
23692370
'multiple' => true, // allow multiple selections
23702371
'include_all_form_fields' => false, // only send the current field through AJAX (for a smaller payload if you're not using multiple chained select2s)
2371-
2372+
23722373
// OPTIONAL - if the response is a list of objects (and not a simple array)
23732374
'attribute' => 'title', // attribute to show in the select2
23742375
'attributes_to_store' => ['id', 'title'], // attributes to store in the database
@@ -2419,7 +2420,7 @@ public function fetchAirports()
24192420

24202421
#### Storing only one the id in the database
24212422

2422-
A very common use case you may have is to store only the id of the selected item in the database instead of a `json` string. For those cases you can achieve that by setting the `attributes_to_store` attribute to an array with only one item, the id of the selected item and do a little trick with the model events to store the id you want, and to give the field that id in a way it understands.
2423+
A very common use case you may have is to store only the id of the selected item in the database instead of a `json` string. For those cases you can achieve that by setting the `attributes_to_store` attribute to an array with only one item, the id of the selected item and do a little trick with the model events to store the id you want, and to give the field that id in a way it understands.
24232424

24242425
```php
24252426

@@ -2428,7 +2429,7 @@ CRUD::field([
24282429
'type' => 'select2_json_from_api',
24292430
'name' => 'airport_id', // dont make your column json if not storing json on it!
24302431
// .... the rest your field configuration
2431-
'attribute' => 'id',
2432+
'attribute' => 'id',
24322433
'attributes_to_store' => ['id'],
24332434
'events' => [
24342435
'saving' => function($entry) {
@@ -2445,7 +2446,7 @@ CRUD::field([
24452446

24462447
### slug <span class="badge badge-pill badge-info">PRO</span>
24472448

2448-
Track the value of a different text input and turn it into a valid URL segment (aka. slug), as you type, using Javascript. Under the hood it uses [slugify](https://github.com/simov/slugify/blob/master/README.md) to generate the slug with some sensible defaults.
2449+
Track the value of a different text input and turn it into a valid URL segment (aka. slug), as you type, using Javascript. Under the hood it uses [slugify](https://github.com/simov/slugify/blob/master/README.md) to generate the slug with some sensible defaults.
24492450

24502451
```php
24512452
CRUD::field([ // Text

0 commit comments

Comments
 (0)