Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
Administrator
Platform
Commits
62eeb8c1
Unverified
Commit
62eeb8c1
authored
Aug 29, 2018
by
Nicolas Widart
Committed by
GitHub
Aug 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #579 from chiragpipariya/patch-2
i18nFile & normalFile added two function
parents
31bec710
b473471b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
macros.php
Modules/Core/macros.php
+45
-0
No files found.
Modules/Core/macros.php
View file @
62eeb8c1
...
@@ -176,6 +176,32 @@ Form::macro('i18nSelect', function ($name, $title, ViewErrorBag $errors, $lang,
...
@@ -176,6 +176,32 @@ Form::macro('i18nSelect', function ($name, $title, ViewErrorBag $errors, $lang,
return
new
HtmlString
(
$string
);
return
new
HtmlString
(
$string
);
});
});
Form
::
macro
(
'i18nFile'
,
function
(
$name
,
$title
,
ViewErrorBag
$errors
,
$lang
,
$object
=
null
,
array
$options
=
[])
{
if
(
array_key_exists
(
'multiple'
,
$options
))
{
$nameForm
=
"
{
$lang
}
[
$name
][]"
;
}
else
{
$nameForm
=
"
{
$lang
}
[
$name
]"
;
}
$options
=
array_merge
([
'class'
=>
'form-control'
],
$options
);
$string
=
"<div class='form-group "
.
(
$errors
->
has
(
$lang
.
'.'
.
$name
)
?
' has-error'
:
''
)
.
"'>"
;
$string
.=
"<label for='
$nameForm
'>
$title
</label>"
;
if
(
is_object
(
$object
))
{
$currentData
=
$object
->
hasTranslation
(
$lang
)
?
$object
->
translate
(
$lang
)
->
{
$name
}
:
''
;
}
else
{
$currentData
=
false
;
}
$string
.=
Form
::
file
(
"
{
$lang
}
[
{
$name
}
]"
,
$options
);
$string
.=
$errors
->
first
(
"
{
$lang
}
.
{
$name
}
"
,
'<span class="help-block">:message</span>'
);
$string
.=
'</div>'
;
return
new
HtmlString
(
$string
);
});
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
| Standard fields
| Standard fields
...
@@ -346,6 +372,25 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array
...
@@ -346,6 +372,25 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array
return
new
HtmlString
(
$string
);
return
new
HtmlString
(
$string
);
});
});
Form
::
macro
(
'normalFile'
,
function
(
$name
,
$title
,
ViewErrorBag
$errors
,
$object
=
null
,
array
$options
=
[])
{
$options
=
array_merge
([
'class'
=>
'form-control'
,
'placeholder'
=>
$title
,
'multiple'
=>
'multiple'
],
$options
);
$string
=
"<div class='form-group "
.
(
$errors
->
has
(
$name
)
?
' has-error'
:
''
)
.
"'>"
;
$string
.=
Form
::
label
(
$name
,
$title
);
if
(
is_object
(
$object
))
{
$currentData
=
$object
->
{
$name
}
?:
''
;
}
else
{
$currentData
=
null
;
}
$string
.=
Form
::
file
(
$name
,
$options
);
$string
.=
$errors
->
first
(
$name
,
'<span class="help-block">:message</span>'
);
$string
.=
'</div>'
;
return
new
HtmlString
(
$string
);
});
Response
::
macro
(
'csv'
,
function
(
$file
,
$filename
,
$status
=
200
,
$headers
=
[])
{
Response
::
macro
(
'csv'
,
function
(
$file
,
$filename
,
$status
=
200
,
$headers
=
[])
{
return
response
(
$file
,
$status
,
array_merge
([
return
response
(
$file
,
$status
,
array_merge
([
'Content-Type'
=>
'application/csv'
,
'Content-Type'
=>
'application/csv'
,
...
...
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