Commit 7fb422db authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-1978: Adding validation for twitter.

parent ccfa2684
...@@ -431,15 +431,33 @@ function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter( ...@@ -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. // 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'; $form['actions']['submit']['#submit'][] = 'uw_virtual_site_homepage_node_form_redirect';
// Adding the validate for removing duplicate buttons. // Adding the validate for twitter.
$form['#validate'][] = 'uw_virtual_site_homepage_button_validate'; $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.');
}
}
}
}
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment