新增 form 组件字段可变

This commit is contained in:
JaguarJack 2021-05-03 14:47:30 +08:00
parent afeca7286c
commit c221f0fe4a

View File

@ -193,10 +193,10 @@ abstract class Form
* @param string $value * @param string $value
* @return mixed * @return mixed
*/ */
public static function image(string $title, string $value = ''): Upload public static function image(string $title, string $field = 'image', string $value = ''): Upload
{ {
return self::uploadImage('image', $title, self::uploadImageUrl(), $value) return self::uploadImage($field, $title, self::uploadImageUrl(), $value)
->uploadName('image') ->uploadName($field)
->data(['none' => '']) ->data(['none' => ''])
->headers(self::authorization()); ->headers(self::authorization());
} }
@ -209,10 +209,10 @@ abstract class Form
* @param array $value * @param array $value
* @return mixed * @return mixed
*/ */
public static function images(string $title, array $value = []): Upload public static function images(string $title, $field = 'images', array $value = []): Upload
{ {
return self::uploadImages('image', $title, self::uploadImageUrl(), $value) return self::uploadImages($field, $title, self::uploadImageUrl(), $value)
->uploadName('image') ->uploadName($field)
->data(['none' => '']) ->data(['none' => ''])
->headers(self::authorization()); ->headers(self::authorization());
} }
@ -225,10 +225,10 @@ abstract class Form
* @param string $value * @param string $value
* @return Upload * @return Upload
*/ */
public static function file(string $title, string $value = ''): Upload public static function file(string $title, $field = 'file', string $value = ''): Upload
{ {
return self::uploadFile('file', $title, self::uploadFileUrl(), $value) return self::uploadFile($field, $title, self::uploadFileUrl(), $value)
->uploadName('image') ->uploadName($field)
->data(['none' => '']) ->data(['none' => ''])
->headers(self::authorization()); ->headers(self::authorization());
} }
@ -241,10 +241,10 @@ abstract class Form
* @param array $value * @param array $value
* @return Upload * @return Upload
*/ */
public static function files(string $title, array $value = []): Upload public static function files(string $title, $field = 'files',array $value = []): Upload
{ {
return self::uploadFiles('file', $title, self::uploadFileUrl(), $value) return self::uploadFiles($field, $title, self::uploadFileUrl(), $value)
->uploadName('file') ->uploadName($field)
->data(['none' => '']) ->data(['none' => ''])
->headers(self::authorization()); ->headers(self::authorization());
} }