ljfphp
- ljfphp 赞了回答
楼上正解,
andWhere($condition, $params = [])
,三个参数值是作为$condition的数组,不存在三个参数的写法,用方法前要看下方法的使用呢。`/*** Adds an additional WHERE condition to the existing one. * The new condition and the existing one will be joined using the `AND` operator. * @param string|array|ExpressionInterface $condition the new WHERE condition. Please refer to [[where()]] * on how to specify this parameter. * @param array $params the parameters (name => value) to be bound to the query. * @return $this the query object itself * @see where() * @see orWhere() */`
- ljfphp 回答了问题 请问一下 Yii2 框架如何发送邮件呢?
1、配置文件配置一下
2、代码里面直接发就OK,代码参考博客
https://blog.csdn.net/qq_34193883/article/details/82895578我的代码和这个博客的差不多,已经成功发送邮件
比如我在rules里面用到这个条件,不过没什么用。本意是在repository_key 这个值等于1的时候,才去验证其他的几个参数。
[['repository', 'staff','svn_name'], 'required', 'when' => function ($model) { if($model->repository_key == 1){ return true; }else{ return false; } }, 'on' => 'assgin', ],
最后补充:
功能已经完成了,是$model初始值的问题,当$model初始值没问题的时候,下拉框是正常的,可以区分enabled和disabled。但是我这个问题还是不大懂,为什么我重新给它赋值就没用呢?就算初始的$model为空,那我下面的赋值也成功了,为什么就是不能正常显示,百思不得其解`
public static function listBox($name, $selection = null, $items = [], $options = [])
参数及使用:
1
$name:设置select的name字符串,这个用来设置生成的select标签的name值
2
$selection:设置select中哪位为选中字符串或者数组,这个用来设置哪个option为选中状态,因为select只能有一个option为选中。所以如果为数组的话后面匹配的值会覆盖前面匹配的值。
`
目前怀疑是要用到这个
$selection
属性吗,我用model赋值,和用options方式赋值都失败了1、$model->status =2; 2、4'=>['selected'=>'selected']]
![_@C6QGLU5)84[[V%BFPRN2Q.png](/uploads/images/201903/12091442617.png "_@C6QGLU5)84[[V%BFPRN2Q.png")