amis-admin icon indicating copy to clipboard operation
amis-admin copied to clipboard

combo组件怎么用

Open VetorPers opened this issue 2 years ago • 5 comments

像input_array 和combo组件用不了呢,点击新增没反应 InputArray::make() ->items([ $form->item("", "文字")->useFormItem(), ])

VetorPers avatar Sep 06 '23 07:09 VetorPers

Combo::make()
            ->multiLine(true)
            ->items(function () {
                $language = Language::query()->orderBy('order')->get();
                $items = [];
                foreach ($language as $lang) {
                    if ($lang->show) {
                        $items[] = InputImage::make()->name($lang->slug)->label($lang->name)->uniqueName()->fixedSize(false)->fixedSizeClassName('h-30');
                    }
                }
                return $items;
            });

SmallRuralDog avatar Sep 26 '23 10:09 SmallRuralDog

combo 里的组件需要指定 namelabel

SmallRuralDog avatar Sep 26 '23 10:09 SmallRuralDog

好的,谢谢

VetorPers avatar Sep 26 '23 10:09 VetorPers

@SmallRuralDog 加上multiple还是不行呢,主要是想用新增的功能。是我姿势不正确吗

Combo::make()
                    ->multiLine(true)
                    ->multiple(true)
                    ->items(function () {
                        return [
                            InputImage::make()->name('name')->label('label'),
                            InputImage::make()->name('name')->label('label'),
                        ];
                    }),

VetorPers avatar Sep 27 '23 03:09 VetorPers

一对多, Combo items这里应该如何写呢

models 
public function 详情(){
        return $this->hasMany(详情::class,'详情id','id');
    }


Controller.php
  $form->item('详情')
                      ->useFormItem(
                          Combo::make()
                          ->multiLine(true)
                          ->items(function () {
                              return [
                                   InputText::make()->name('详情姓名')->label('详情姓名'),
                                  InputText::make()->name('详情时间')->label('详情时间'),
                              ];
                          }),
                      ),

chenjiabin avatar May 02 '24 18:05 chenjiabin