@@ -58,6 +58,8 @@ class FormItem
58
58
'anyValue ' => false ,
59
59
];
60
60
61
+ protected $ vifEval ;
62
+
61
63
/**
62
64
* FormItem constructor.
63
65
* @param $prop
@@ -127,9 +129,9 @@ public function footerComponent($component)
127
129
}
128
130
129
131
/**
130
- * @deprecated
131
132
* @param $component
132
133
* @return $this
134
+ * @deprecated
133
135
*/
134
136
public function displayComponent ($ component )
135
137
{
@@ -240,7 +242,7 @@ public function defaultValue($defaultValue)
240
242
{
241
243
$ this ->defaultValue = $ defaultValue ;
242
244
243
- if ($ this ->component ) $ this ->component ->componentValue ($ defaultValue );
245
+ if ($ this ->component ) $ this ->component ->componentValue ($ defaultValue );
244
246
245
247
return $ this ;
246
248
}
@@ -449,6 +451,7 @@ public function help($help)
449
451
/**
450
452
* @param $key
451
453
* @param $value
454
+ * @param bool $anyValue
452
455
* @return $this
453
456
*/
454
457
public function vif ($ key , $ value , $ anyValue = false )
@@ -461,6 +464,21 @@ public function vif($key, $value, $anyValue = false)
461
464
return $ this ;
462
465
}
463
466
467
+ /**
468
+ * @param \Closure $closure
469
+ * @return FormItem
470
+ */
471
+ public function vifEval (\Closure $ closure )
472
+ {
473
+ $ vifEval = new Form \Utils \VIfEval ();
474
+
475
+ call_user_func ($ closure , $ vifEval );
476
+
477
+ $ this ->vifEval = $ vifEval ->build ();
478
+ return $ this ;
479
+ }
480
+
481
+
464
482
/**
465
483
* 设置字段所属tab名称
466
484
* @param string $tab
@@ -489,16 +507,18 @@ public function ignoreEmpty()
489
507
$ this ->ignoreEmpty = true ;
490
508
return $ this ;
491
509
}
510
+
492
511
/**
493
512
* 传递当前组件所在模式
494
- * @param string $value
513
+ * @param string $value
495
514
* @return $this
496
515
*/
497
516
public function hiddenMode ($ value = '' )
498
517
{
499
518
$ this ->hiddenMode = $ value ;
500
519
return $ this ;
501
520
}
521
+
502
522
/**
503
523
* @return mixed
504
524
*/
@@ -507,6 +527,7 @@ public function hiddenInCreate()
507
527
$ this ->hiddenMode = Form::MODE_CREATE ;
508
528
return $ this ;
509
529
}
530
+
510
531
/**
511
532
* @return mixed
512
533
*/
@@ -515,13 +536,15 @@ public function hiddenInEdit()
515
536
$ this ->hiddenMode = Form::MODE_EDIT ;
516
537
return $ this ;
517
538
}
539
+
518
540
/**
519
541
* @return mixed
520
542
*/
521
543
public function getHiddenMode ()
522
544
{
523
545
return $ this ->hiddenMode ;
524
546
}
547
+
525
548
public function getAttrs ()
526
549
{
527
550
return [
@@ -543,7 +566,8 @@ public function getAttrs()
543
566
'relationName ' => $ this ->relationName ,
544
567
'relationValueKey ' => $ this ->relationValueKey ,
545
568
'vif ' => $ this ->vif ,
546
- 'tab ' =>$ this ->tab ,
569
+ 'vifEval ' => $ this ->vifEval ,
570
+ 'tab ' => $ this ->tab ,
547
571
'ignoreEmpty ' => $ this ->ignoreEmpty ,
548
572
'hiddenMode ' => $ this ->hiddenMode ,
549
573
];
0 commit comments