",
);
$form['view_setup_table']["fields_name_$mview_id-$i"] = array(
'#type' => 'markup',
'#attributes' => array('class' => 'fields-column-name'),
'#value' => "
$column_name".
"
$column_type
",
);
$data['field_types'][$column_name] = $column_type;
$table = $form_state['storage']["fields_join_$mview_id-$i"];
$form['view_setup_table']["fields_join_$mview_id-$i"] = array(
'#type' => 'select',
'#prefix' => "
",
'#suffix' => "
",
'#options' => $chado_tables,
'#required' => FALSE,
'#default_value' => $table,
'#ahah' => array(
'path' => ahah_helper_path(array("view_setup_table","fields_join_column_$mview_id-$i")),
'wrapper' => "fields-column-join-column-$mview_id-$i",
'effect' => 'fade',
'event' => 'change',
'method' => 'replace',
),
);
if($table){
$table_desc = module_invoke_all('chado_'.$table.'_schema');
$columns = array_keys($table_desc['fields']);
} else {
$columns = array();
}
$form['view_setup_table']["fields_join_column_$mview_id-$i"] = array(
'#type' => 'select',
'#prefix' => "
",
'#suffix' => "
",
'#options' => $columns,
'#required' => FALSE,
);
$form['view_setup_table']["fields_filter_handler_$mview_id-$i"] = array(
'#type' => 'select',
'#prefix' => "
",
'#suffix' => "
",
'#options' => $handlers_filters,
'#required' => FALSE,
);
$form['view_setup_table']["fields_field_handler_$mview_id-$i"] = array(
'#type' => 'select',
'#prefix' => "
",
'#suffix' => "
",
'#options' => $handlers_fields,
'#required' => FALSE,
);
$form['view_setup_table']["fields_end_$i"] = array(
'#type' => 'markup',
'#value' => "
",
);
$i++;
}
$form['view_setup_table']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$data['row_count'] = $i - 1;
}
//use this to put values into $form_state['values']
$form['data'] = array();
//need to find out if storing $form['data'][$key]['#value'] = $value <- is an issue
//since it will give me errors if i try to stare an array instead of $value
//and yet $value can be an array ie "field_types"
foreach ($data as $key => $value) {
$form['data'][$key] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
return $form;
}
/**
*
* @ingroup tripal_views_integration
*/
function tripal_core_views_integration_new_setup_form_validate($form, &$form_state){
$name_array = explode(" ", $form_state['values']['row_name']);
if(count($name_array) > 1){
form_set_error($form_state['values']['row_name'], 'Name must be ONE word only.');
}
//TODO: write validation function for this new form
}
/**
*
* @ingroup tripal_views_integration
*/
function tripal_core_views_integration_new_setup_form_submit($form, &$form_state){
$name = $form_state['values']['row_name'];
$mview_id = $form_state['values']['mview_id'];
$tripal_views_integration_record = array(
'mview_id' => $mview_id,
'name' => $name,
'description' => $form_state['values']['row_description'],
);
drupal_write_record('tripal_views_integration', $tripal_views_integration_record);
$i = 1;
foreach ($form_state['values']['field_types'] as $key => $value){
$mview_join_record = array(
'setup_id' => $tripal_views_integration_record['setup_id'],
'view_table' => $form['mview_id']['#options'][$form_state['values']['mview_id']],
'view_column' => $key,
'chado_table_join' => $form_state['values']["fields_join_$mview_id-$i"],
'chado_column' => $form['view_setup_table']["fields_join_column_$mview_id-$i"]['#options'][$form_state['values']["fields_join_column_$mview_id-$i"]],
);
drupal_write_record('tripal_mviews_join', $mview_join_record);
$handlers_record = array(
'setup_id' => $tripal_views_integration_record['setup_id'],
'column_name' => $key,//TODO: should we change this to an mview_join_id from tripal_view_join?
'handler_filter' => $form['view_setup_table']["fields_filter_handler_$mview_id-$i"]['#options'][$form_state['values']["fields_filter_handler_$mview_id-$i"]],
'handler_field' => $form['view_setup_table']["fields_field_handler_$mview_id-$i"]['#options'][$form_state['values']["fields_field_handler_$mview_id-$i"]],
);
drupal_write_record('tripal_views_handlers', $handlers_record);
$i++;
}
}