Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-forms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-forms
Merge requests
!6
feat(form): Action/method attribute for form
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
feat(form): Action/method attribute for form
feature/form-action
into
master
Overview
1
Commits
2
Pipelines
1
Changes
7
Merged
Krzysztof Dyszczyk
requested to merge
feature/form-action
into
master
5 years ago
Overview
1
Commits
2
Pipelines
1
Changes
7
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
84800450
2 commits,
5 years ago
7 files
+
120
−
43
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
src/Field/Traits/HtmlAttributes.php
0 → 100644
+
69
−
0
View file @ 84800450
Edit in single-file editor
Open in Web IDE
<?php
namespace
WPDesk\Forms\Field\Traits
;
/**
* Implementation of HTML attributes like id, name, action etc.
*
* @package WPDesk\Forms\Field\Traits
*/
trait
HtmlAttributes
{
/** @var string[] */
protected
$attributes
;
/**
* Get list of all attributes except given.
*
* @param string[] $except
*
* @return string[]
*/
public
function
get_attributes
(
$except
=
[]
)
{
return
array_filter
(
$this
->
attributes
,
function
(
$value
,
$key
)
use
(
$except
)
{
return
!
in_array
(
$key
,
$except
,
true
);
},
ARRAY_FILTER_USE_BOTH
);
}
/**
* @param string $name
* @param string $value
*
* @return $this
*/
public
function
set_attribute
(
$name
,
$value
)
{
$this
->
attributes
[
$name
]
=
$value
;
return
$this
;
}
/**
* @param string $name
*
* @return $this
*/
public
function
unset_attribute
(
$name
)
{
unset
(
$this
->
attributes
[
$name
]
);
return
$this
;
}
/**
* @param string $name
*
* @return bool
*/
public
function
is_attribute_set
(
$name
)
{
return
isset
(
$this
->
attributes
[
$name
]
);
}
/**
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public
function
get_attribute
(
$name
,
$default
=
null
)
{
return
isset
(
$this
->
attributes
[
$name
]
)
?:
$default
;
}
}
\ No newline at end of file
Loading