Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
wcms-openscholar
uw_virtual_site_homepage
Commits
7fb422db
Commit
7fb422db
authored
Apr 17, 2017
by
Eric Bremner
Browse files
ISTWCMS-1978: Adding validation for twitter.
parent
ccfa2684
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
uw_virtual_site_homepage.module
uw_virtual_site_homepage.module
+22
-4
No files found.
uw_virtual_site_homepage.module
View file @
7fb422db
...
...
@@ -431,15 +431,33 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(
// Adding the redirect back to the homepage after the save of the uw_virtual_site_homepage.
$form
[
'actions'
][
'submit'
][
'#submit'
][]
=
'uw_virtual_site_homepage_node_form_redirect'
;
// Adding the validate for
removing duplicate buttons
.
$form
[
'#validate'
][]
=
'uw_virtual_site_homepage_
button
_validate'
;
// Adding the validate for
twitter
.
$form
[
'#validate'
][]
=
'
_
uw_virtual_site_homepage_
twitter
_validate'
;
}
/**
* The validate
buttons by adding css in order to remove duplicate buttons
.
* The validate
for twitter
.
*/
function
uw_virtual_site_homepage_
button
_validate
(
&
$form
,
&
$form_state
)
{
function
_
uw_virtual_site_homepage_
twitter
_validate
(
&
$form
,
&
$form_state
)
{
// If there is a twitter username.
if
(
isset
(
$form_state
[
'values'
][
'field_uw_twitter_username'
][
LANGUAGE_NONE
][
0
][
'value'
]))
{
// If the twitter username has a value.
if
(
$form_state
[
'values'
][
'field_uw_twitter_username'
][
LANGUAGE_NONE
][
0
][
'value'
]
!==
""
)
{
// If there is a twitter type.
if
(
isset
(
$form_state
[
'values'
][
'field_uw_twitter_type'
][
LANGUAGE_NONE
][
0
]))
{
// If the twitter type has no value, set a form error.
if
(
$form_state
[
'values'
][
'field_uw_twitter_type'
][
LANGUAGE_NONE
][
0
][
'value'
]
==
NULL
)
{
// Set the form error.
form_set_error
(
'field-uw-twitter-username'
,
'You must select a place to display the twitter feed.'
);
}
}
}
}
}
/**
...
...
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