Comments Xuân An started the conversationApril 23, 2022 at 3:39amHi Admin,I have array author array (size=6) 39 => string 'Hữu Hồng Minh Nguyễn' (length=26) 40 => string 'Nguyệt Minh Lê' (length=17) 41 => string 'Thị Ngọc Mai Trần' (length=23) 42 => string 'Hoàng Anh Châu Nguyễn' (length=25) 43 => string 'Sơn Trà Nguyễn' (length=18) 77 => string 'System Admin' (length=12)I would like choose id= 40 to default.I find source code show authors and I edit but it do not effect.$form ->setValidatorClass(CustomPostRequest::class) ->addAfter('status', 'author_id', 'customSelect', [ 'label' => __('Author'), 'label_attr' => ['class' => 'control-label required'], 'attr' => [ 'placeholder' => __('Select an author...'), ], 'choices' => $authorsArray, ]);Please help me edit it.Thanks! 252The repliedApril 23, 2022 at 9:53am Hi,You just need to add'default value' => $defaultValue $form ->setValidatorClass(CustomPostRequest::class) ->addAfter('status', 'author_id', 'customSelect', [ 'label' => __('Author'), 'label_attr' => ['class' => 'control-label required'], 'attr' => [ 'placeholder' => __('Select an author...'), ], 'choices' => $authorsArray, 'default value' => $defaultValue ]); Xuân An repliedApril 23, 2022 at 10:22amHi admin,I add some case but not effect 'default value' => '40' 'default value' => 'Nguyệt Minh Lê'or $b = new ArrayObject(); $b['40'] = 'Nguyệt Lê Minh';'default value' => $bThanks! 252The repliedApril 25, 2022 at 12:32amHi Xuan An,We typed it wrong. Exactly like the attached picture.1 Like Sign in to reply ...
Hi Admin,
I have array author
I would like choose id= 40 to default.
I find source code show authors and I edit but it do not effect.
$form
->setValidatorClass(CustomPostRequest::class)
->addAfter('status', 'author_id', 'customSelect', [
'label' => __('Author'),
'label_attr' => ['class' => 'control-label required'],
'attr' => [
'placeholder' => __('Select an author...'),
],
'choices' => $authorsArray,
]);
Please help me edit it.
Thanks!
Hi,
You just need to add
'default value' => $defaultValue
Hi admin,
I add some case but not effect
or
$b = new ArrayObject();
$b['40'] = 'Nguyệt Lê Minh';
'default value' => $b
Thanks!
Hi Xuan An,
We typed it wrong. Exactly like the attached picture.