Commit 5e099cdf authored by metzlerd's avatar metzlerd
Browse files

UI Tweaks. Minor.

parent 5036349a
......@@ -1576,3 +1576,65 @@ function forena_requirements($phase) {
}
return $requirements;
}
/**
* Custom override of machine_name validate that does not include
* @param unknown $element
* @param unknown $form_state
*/
function forena_machine_name_validate($element, &$form_state) {
// Verify that the machine name not only consists of replacement tokens.
if (preg_match('@^' . $element['#machine_name']['replace'] . '+$@', $element['#value'])) {
form_error($element, t('The machine-readable name must contain unique characters.'));
}
// Verify that the machine name contains no disallowed characters.
if (preg_match('@' . $element['#machine_name']['replace_pattern'] . '@', $element['#value'])) {
if (!isset($element['#machine_name']['error'])) {
// Since a hyphen is the most common alternative replacement character,
// a corresponding validation error message is supported here.
if ($element['#machine_name']['replace'] == '-') {
form_error($element, t('The machine-readable name must contain only letters, numbers, and hyphens.'));
}
// Otherwise, we assume the default (underscore).
else {
form_error($element, t('The machine-readable name must contain only letters, numbers, and underscores.'));
}
}
else {
form_error($element, $element['#machine_name']['error']);
}
}
}
function forena_process_machine_name($element, &$form_state) {
$element['#machine_name']['replace_pattern'] = '[^A-Za-z0-9_\.\/]+';
return $element;
}
/**
* Create a derivative to the machine name field with relaxed restrictions.
* @return multitype:boolean string NULL number multitype:string
*/
function forena_element_info() {
$types['forena_machine_name'] = array(
'#input' => TRUE,
'#element_validate' => array('forena_machine_name_validate'),
'#default_value' => NULL,
'#size' => 60,
'#maxlength' => 64,
'#required' => TRUE,
'#autocomplete_path' => FALSE,
'#process' => array(
'form_process_machine_name',
'forena_process_machine_name',
'ajax_process_form',
),
'#theme_wrappers' => array('form_element'),
'#theme' => 'textfield',
);
return $types;
}
\ No newline at end of file
......@@ -44,24 +44,25 @@ function forena_add_report_form($formid, $form_state, $report_name='') {
//list of supported document formats
$doclist = variable_get('forena_doc_formats', array());
$form['report_name'] = array(
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $title,
'#required' => TRUE,
);
$form['report_name'] = array(
'#type' => 'forena_machine_name',
'#title' => t('Report Name'),
'#description' => t('Enter only letters, numbers, and special characters: - _ /
<br/>White space is not permitted.
Create a directory using the format: (directory name) / (report name). Save multiple reports to the same directory
by referencing the same name.'),
'#required' => TRUE,
'#machine_name' => array('source' => array('report_name'), 'label' => 'Report_name'),
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $title,
'#required' => TRUE,
);
$form['category'] = array(
'#type' => 'textfield',
'#title' => t('Category'),
......@@ -1069,6 +1070,13 @@ function forena_report_parameter_config_form($formid, $form_state, $report_name,
'#value' => $id,
);
$form['parm']['id_label'] = array(
'#type' => 'item',
'#title' => t('Name'),
'#markup' => $id,
'#description' => t('The machine friendly name of the parameter as used in the query or report. ')
);
$form['parm']['label'] = array(
'#type' => 'textfield',
'#title' => t('label'),
......@@ -1308,14 +1316,20 @@ function forena_report_add_parameter_form($form, &$form_state, $report_name) {
);
$form['parameters'] = array('#tree' => TRUE);
$form['parameters']['label'] = array(
'#type' => 'textfield',
'#title' => t("Label"),
'#description' => t('The Label to display to the user. ')
);
$form['parameters']['id'] = array(
'#type' => 'textfield',
'#type' => 'forena_machine_name',
'#title' => t('id'),
'#required' => TRUE,
'#description' => t('The name of the parameter to be filtered against.')
'#description' => t('The machine friendly name of the as used in queries or reports.')
);
$form['add'] = array(
'#type' => 'submit',
'#value' => t('Add'),
......
......@@ -24,7 +24,7 @@ function forena_query_create_block_form($form, &$form_state, $provider='') {
);
$form['block_name'] = array(
'#type' => 'textfield',
'#type' => 'forena_machine_name',
'#required' => TRUE,
'#title' => t('Block to create'),
);
......@@ -77,6 +77,12 @@ function forena_query_sql_editor($form, &$form_state, $block_name='') {
$block_name = $form_state['storage']['block_name'];
$o = Frx::BlockEditor($block_name);
$block = $o->block;
$form['block_label'] = array(
'#type' => 'item',
'#title' => t('Query (data block) name'),
'#markup' => str_replace('.', '/', $block_name),
);
$form['access'] = array(
'#title' => t('Data Security'),
......
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