#3133 fast add user select

This commit is contained in:
Diatrex 2021-01-27 12:07:34 +03:00
parent 7e93deea32
commit c3cc0cd12a
3 changed files with 16 additions and 0 deletions

View File

@ -322,6 +322,8 @@ return [
'upload_files' => 'Upload Files',
'additional_fields' => 'Additional Fields',
'ad_location' => 'Ad Location',
'owner' => 'Owner',
'default_owner_instruction' => 'The owner will default to the current user if no user is selected',
'free' => 'Free',
'ad_date' => 'Ad Date',

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\AdvsModule\Adv\Form;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
use Anomaly\UsersModule\User\UserModel;
use Visiosoft\AdvsModule\Adv\AdvModel;
class SimpleAdvFormBuilder extends FormBuilder
@ -8,6 +9,15 @@ class SimpleAdvFormBuilder extends FormBuilder
protected $model = AdvModel::class;
protected $fields = [
"created_by_id" => [
'label' => 'visiosoft.module.advs::field.owner',
'instructions' => 'visiosoft.module.advs::field.default_owner_instruction',
"type" => "anomaly.field_type.relationship",
"config" => [
"related" => UserModel::class,
"mode" => "lookup",
]
],
'name',
'price',
'currency',

View File

@ -11,6 +11,10 @@ class SimpleAdvFormHandler
return;
}
if (!$builder->getFormValue('created_by_id')) {
$builder->setFormValue('created_by_id', auth()->id());
}
$builder->saveForm();
$ad = $advRepository->find($builder->getFormEntryId());