Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
clientside_validation
Commits
a4d76661
Commit
a4d76661
authored
Apr 30, 2012
by
Jelle Sebreghts
Browse files
Issue #1543742 by peskydonut: Added Custom validation using #element_validate().
parent
46b3a3b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
clientside_validation_form/clientside_validation_form.module
View file @
a4d76661
...
...
@@ -12,12 +12,16 @@ function clientside_validation_form_after_build_recurse($form_id, &$form, &$form
if
(
$children
=
array_values
(
element_children
(
$form
)))
{
foreach
(
$children
as
$index
=>
$item
)
{
$element
=
&
$form
[
$item
];
/*
$types = array(
$types
=
array
(
'textfield'
,
'textarea'
,
'select'
,
'radio'
,
'checkbox'
,
'password'
,
'managed_file'
,
'file'
,
'radios'
,
'checkboxes'
,
'link_field'
,
);
*/
if
(
isset
(
$element
[
'#type'
])
/*
&& in_array($element['#type'], $types)
*/
)
{
);
if
(
isset
(
$element
[
'#type'
])
&&
in_array
(
$element
[
'#type'
],
$types
))
{
clientside_validation_regular
(
$form_id
,
$element
,
$js_rules
,
$form_state
);
}
if
(
isset
(
$element
[
'#element_validate'
])
&&
!
empty
(
$element
[
'#element_validate'
]))
{
$context
=
array
(
'type'
=>
'element_validate'
,
'functions'
=>
$element
[
'#element_validate'
]);
drupal_alter
(
'clientside_validation_rule'
,
$js_rules
,
$element
,
$context
);
}
clientside_validation_form_after_build_recurse
(
$form_id
,
$element
,
$form_state
,
$js_rules
);
}
}
...
...
@@ -156,10 +160,6 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
break
;
}
}
if
(
isset
(
$element
[
'#element_validate'
])
&&
!
empty
(
$element
[
'#element_validate'
]))
{
$context
=
array
(
'type'
=>
'element_validate'
,
'functions'
=>
$element
[
'#element_validate'
]);
drupal_alter
(
'clientside_validation_rule'
,
$js_rules
,
$element
,
$context
);
}
}
function
clientside_validation_form_field_info_alter
(
&
$info
)
{
...
...
Write
Preview
Supports
Markdown
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