Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
fcb6f59c
Commit
fcb6f59c
authored
Sep 10, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加图片选项
parent
80f2bde6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
ArticleForm.php
backend/models/coin/ArticleForm.php
+5
-3
_form-article.php
backend/views/source/_form-article.php
+33
-3
No files found.
backend/models/coin/ArticleForm.php
View file @
fcb6f59c
...
...
@@ -16,6 +16,7 @@ class ArticleForm extends Model
public
$title
;
public
$url
;
public
$status
;
public
$image_url
;
public
function
formName
()
{
...
...
@@ -25,15 +26,16 @@ class ArticleForm extends Model
public
function
rules
()
{
return
[
[[
'title'
,
'url'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'title'
,
'url'
],
'required'
,
'on'
=>
'edit'
],
[[
'title'
,
'image_url'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'title'
],
'required'
,
'on'
=>
'edit'
],
[[
'url'
],
'safe'
]
];
}
public
function
scenarios
()
{
return
[
'add'
=>
[
'title'
,
'url'
,
'status'
],
'add'
=>
[
'title'
,
'url'
,
'status'
,
'image_url'
],
'edit'
=>
[
'id'
,
'title'
,
'url'
,
'status'
],
];
}
...
...
backend/views/source/_form-article.php
View file @
fcb6f59c
...
...
@@ -26,8 +26,7 @@
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
外链地址
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
type=
"text"
value=
"
<?=
$model
->
url
?>
"
lay-verify=
"required|url"
name=
"url"
>
<input
class=
"layui-input"
type=
"text"
value=
"
<?=
$model
->
url
?>
"
name=
"url"
>
</div>
</div>
...
...
@@ -40,7 +39,20 @@
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
图片
</label>
<div
class=
"layui-input-block"
>
<img
src=
""
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon1"
>
</div>
<input
type=
"hidden"
name=
"image_url"
value=
""
lay-verify=
"required|image_url"
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload1"
style=
""
>
<i
class=
"layui-icon"
>

</i>
上传新图片
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn"
lay-submit
>
保存
</button>
</div>
...
...
@@ -50,4 +62,21 @@
<script>
var
form
=
layui
.
form
;
form
.
render
(
null
,
'form1'
);
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
,
image_type
:
2
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
)
{
$
(
"input[name='image_url']"
).
val
(
res
.
data
.
image_src
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
</script>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment