You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change the languages available to translate to/from, in your crud config file (```config/backpack/crud.php```). By default there are quite a few enabled (English, French, German, Italian, Romanian).
385
379
380
+
381
+
#### Updating and creating translatable entries
382
+
383
+
When you're creating a translatable entry, the entry will be created in the current user app locale. Either the one set in `config/app.php` or if you allow your admins to change the panel locale, the one set by them will be used.
384
+
385
+
When you update a translatable entry you choose in what language you want to create the translation for, idependently of the panel language or app locale.
386
+
387
+
When the entry has no translations in the chosen language for translation, you will get the option to select another language to copy the translations from.
Additionally, if you have slugs (but only if you need translatable slugs), you'll need to use backpack's classes instead of the ones provided by `cviebrock/eloquent-sluggable`.
387
394
Make sure you have `cviebrock/eloquent-sluggable` installed as well, if not, please do it with `composer require cviebrock/eloquent-sluggable`:
Copy file name to clipboardExpand all lines: 7.x/crud-fields.md
+14-13Lines changed: 14 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -325,7 +325,7 @@ CRUD::field([ // Checklist
325
325
'pivot' => true,
326
326
'show_select_all' => true, // default false
327
327
// 'number_of_columns' => 3,
328
-
328
+
329
329
]);
330
330
```
331
331
@@ -874,7 +874,7 @@ CRUD::field([
874
874
875
875
#### Uploading files with summernote
876
876
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.
878
878
Input preview:
879
879
880
880

@@ -1153,22 +1153,22 @@ CRUD::field([ // Address google
1153
1153
]);
1154
1154
```
1155
1155
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.
1157
1157
1158
1158
**IMPORTANT NOTE**: Your key needs access to the following APIS:
1159
1159
- Maps JavaScript API;
1160
1160
- Places API;
1161
1161
- Geocoding API.
1162
1162
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.
1164
1164
1165
1165
So inside your ```config/services.php``` please add the items below:
1166
1166
```php
1167
1167
'google_places' => [
1168
1168
'key' => 'the-key-you-got-from-google-places'
1169
1169
],
1170
1170
```
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:
1172
1172
```php
1173
1173
[
1174
1174
'name' => 'google_field',
@@ -1445,7 +1445,7 @@ Using Google Places API is dependent on using an API Key. Please [get an API key
1445
1445
- Places API;
1446
1446
- Geocoding API.
1447
1447
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.
1449
1449
1450
1450
**How to save in multiple inputs?**
1451
1451
@@ -1791,7 +1791,7 @@ CRUD::field([
1791
1791
1792
1792
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:
1793
1793
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.
1795
1795
1796
1796
**2)** Add the `id` to your `->withPivot()` fields on your relation. Eg:
1797
1797
```php
@@ -1816,7 +1816,7 @@ CRUD::field([
1816
1816
'name' => 'companies',
1817
1817
'type' => 'relationship',
1818
1818
'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).
// '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;
2184
+
// 'sortable' => true, // requires the field to accept multiple values, and allow the selected options to be sorted.
2184
2185
// 'tagging' => true, // allow users to type and create new options.
2185
2186
]);
2186
2187
```
@@ -2369,7 +2370,7 @@ CRUD::field([
2369
2370
'minimum_input_length' => 2, // minimum characters to type before querying results
2370
2371
'multiple' => true, // allow multiple selections
2371
2372
'include_all_form_fields' => false, // only send the current field through AJAX (for a smaller payload if you're not using multiple chained select2s)
2372
-
2373
+
2373
2374
// OPTIONAL - if the response is a list of objects (and not a simple array)
2374
2375
'attribute' => 'title', // attribute to show in the select2
2375
2376
'attributes_to_store' => ['id', 'title'], // attributes to store in the database
@@ -2420,7 +2421,7 @@ public function fetchAirports()
2420
2421
2421
2422
#### Storing only one the id in the database
2422
2423
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.
2424
+
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.
2424
2425
2425
2426
```php
2426
2427
@@ -2429,7 +2430,7 @@ CRUD::field([
2429
2430
'type' => 'select2_json_from_api',
2430
2431
'name' => 'airport_id', // dont make your column json if not storing json on it!
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.
2450
+
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.
Copy file name to clipboardExpand all lines: 7.x/crud-operation-update.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,7 +335,7 @@ class ProductCrudController extends CrudController
335
335
}
336
336
```
337
337
338
-
>But before you do that, ask yourself - **_is this something that should be done when an entry is added/updated/deleted from the application, too_**? Not just the admin admin? If so, a better place for it would be the Model. Remember your Model is a pure Eloquent Model, so the cleanest way might be to use [Eloquent Event Observers](https://laravel.com/docs/12.x/eloquent#events) or [accessors and mutators](https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators).
338
+
>But before you do that, ask yourself - **_is this something that should be done when an entry is added/updated/deleted from the application, too_**? Not just the admin admin? If so, a better place for it would be the Model. Remember your Model is a pure Eloquent Model, so the cleanest way might be to use [Eloquent Event Observers](https://laravel.com/docs/5.5/eloquent#events) or [accessors and mutators](https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators).
339
339
340
340
<aname="translatable-models"></a>
341
341
### Translatable models and multi-language CRUDs
@@ -383,6 +383,19 @@ class Product extends Model
383
383
384
384
Change the languages available to translate to/from, in your crud config file (```config/backpack/crud.php```). By default there are quite a few enabled (English, French, German, Italian, Romanian).
385
385
386
+
387
+
#### Updating and creating translatable entries
388
+
389
+
When you're creating a translatable entry, the entry will be created in the current user app locale. Either the one set in `config/app.php` or if you allow your admins to change the panel locale, the one set by them will be used.
390
+
391
+
When you update a translatable entry you choose in what language you want to create the translation for, idependently of the panel language or app locale.
392
+
393
+
When the entry has no translations in the chosen language for translation, you will get the option to select another language to copy the translations from.
Additionally, if you have slugs (but only if you need translatable slugs), you'll need to use backpack's classes instead of the ones provided by `cviebrock/eloquent-sluggable`.
387
400
Make sure you have `cviebrock/eloquent-sluggable` installed as well, if not, please do it with `composer require cviebrock/eloquent-sluggable`:
0 commit comments