Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select 单选值不是字符串的时候,选着会提示未选择 #67

Open
varxo opened this issue Jun 29, 2021 · 1 comment
Open

Comments

@varxo
Copy link

varxo commented Jun 29, 2021

No description provided.

@zhangwenfeis
Copy link

转换一下类型就行了

FormBuilder::select( 'cid' , '类别' , (string) $model->cid )->options( function () use ( $vote_id ) {
                
                
                $res = ActivityVoteOptionCateModel::find()
                        ->where( [ 'vote_id' => $vote_id ] )
                        ->andWhereStatusEnable()
                        ->select( [ 'id as value' , 'title as label' ] )
                        ->orderBy( 'sort asc,id desc' )
                        ->asArray()
                        ->all() ?? [];
                
                foreach ( $res as &$item ) {
                    $item[ 'value' ] = (string) $item[ 'value' ];
                }
                
                
                return $res;
            } )->required();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants