[drupal] define validation function for list form
This commit is contained in:
parent
e2e9fee434
commit
7a2f7270be
|
@ -891,6 +891,7 @@ function _logger_sensors_form() {
|
||||||
'#options' => $rows,
|
'#options' => $rows,
|
||||||
'#multiple' => TRUE,
|
'#multiple' => TRUE,
|
||||||
'#default_value' => $defaults,
|
'#default_value' => $defaults,
|
||||||
|
'#element_validate' => array('_logger_sensors_list_validate'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$form['sensors']['submit'] = array
|
$form['sensors']['submit'] = array
|
||||||
|
@ -904,6 +905,11 @@ function _logger_sensors_form() {
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _logger_sensors_list_validate($element, &$form_state) {
|
||||||
|
if (count(array_filter($form_state['values']['list'])) > 5)
|
||||||
|
form_error($element, t('A maximum of five sensors can be plotted on a single chart.'));
|
||||||
|
}
|
||||||
|
|
||||||
function _logger_sensors_submit($form, &$form_state) {
|
function _logger_sensors_submit($form, &$form_state) {
|
||||||
foreach ($form_state['values']['list'] as $sensor => $chart) {
|
foreach ($form_state['values']['list'] as $sensor => $chart) {
|
||||||
if ($chart)
|
if ($chart)
|
||||||
|
|
Loading…
Reference in New Issue