UtuyutuF
03/28/2022, 1:53 AMHữu Hiếu
03/28/2022, 5:43 AMHarings Rob
03/28/2022, 7:23 AMifox
03/28/2022, 7:25 AMconfig('twill.enabled.users-image')kalle
03/28/2022, 7:27 AMifox
03/28/2022, 7:28 AMifox
03/28/2022, 7:28 AMifox
03/28/2022, 7:29 AMkalle
03/28/2022, 7:30 AMHữu Hiếu
03/28/2022, 7:31 AMHữu Hiếu
03/28/2022, 7:58 AMkalle
03/28/2022, 8:53 AMprotected $perPage in Controller ?
Any console errors?kalle
03/28/2022, 10:36 AMphp
@formField('multi_select', [
'name' => 'translate_langs',
'label' => 'Translate langs',
'unpack' => false,
'note' => 'Langs which user can translate',
'default' => 'sr',
'options' => array_map(function($locale) {
return [
'value' => $locale,
'label' => getLanguageLabelFromLocaleCode($locale, true)
];
}, config('translatable.locales', ['sr']))ifox
03/28/2022, 10:38 AMkalle
03/28/2022, 10:38 AMifox
03/28/2022, 10:39 AMkalle
03/28/2022, 10:40 AMifox
03/28/2022, 10:41 AMkalle
03/28/2022, 10:44 AMHarings Rob
03/28/2022, 10:45 AMifox
03/28/2022, 6:16 PMHữu Hiếu
03/28/2022, 6:24 PMrescarcega
03/28/2022, 6:50 PMpublic function prepareFieldsBeforeCreate($fields) {
if($fields['new_name'])
{
$user = new User();
$user->name = $fields['new_name'];
$user->email = $fields['email'];
$user->password = Hash::make($fields['password']);
$user->save();
$fields['user_id'] = $user->id;
}
return parent::prepareFieldsBeforeCreate($fields);
}
I'm having two problems with this code. First, it creates two subscriptions with the new user correctly assigned, and second, if I don't send a new_name, twill will not validate the fields and throw a "Your submission could not be validated, please.....".pboivin
03/28/2022, 7:10 PMprepareFieldsBeforeCreate() is the right hook for your use case. First, I think this runs after your form request is validated, so it's technically too late to trigger the message you're talking about.ifox
03/28/2022, 7:14 PMpboivin
03/28/2022, 7:16 PMrescarcega
03/28/2022, 7:37 PMkalle
03/28/2022, 7:40 PMrescarcega
03/28/2022, 7:41 PM