table select box

jake66

New member
Hi Debbie & Eugenio,
Would one of you be able to point to where the dropdown box allowing the user to select a table that appears in Show All & Last Search Results is built in the code? I would like to make it visible on the search and create new pages as well, if this is possible.

Thanks
Jake
 

DebbieS

DaDaBIK Guru
It is in business_logic.php on or around line 2152 (depending on what mods you've in your file) ... look for the line "function build_change_table_select". To find where other items are built, look through index.php to see what the item is called and then you can find it in business_logic.php.
 

jake66

New member
Hi Debbie,
Thanks for this. I have found the function you refer to and have called it in the Create New page. It works, as in the select box appears, but when I change the option I loose the function=show_insert_form get variable so it changes the table but reverts back to the Last Search Results. Is there anyway round this that you know of?
Thanks
Jake :)
 

DebbieS

DaDaBIK Guru
Not knowing what view you want when selecting the change table box, I can only advise you to look through the function to see where the code is that determines the view upon selection. If you provide me more detail of what your expectations are for this select box on the create view, I will look further.
 

jake66

New member
HI Debbie,
Thanks for your reply. I would like the select box on the create new (and the search) page to change the table enabling the user to search/create in a different table. I have the select box but when I change it, I loose the get variable function so am just left with table=..... which redirects back to last search results. So my question is basically how do I keep that variable that defines the search or create new page (function=show_insert_form or function=show_search_form) intact when I change the table from those pages?
Thanks
Jake
 

DebbieS

DaDaBIK Guru
Ok ... change of plans ... go into business_logic.php and find the function named in the code sample below. Insert the BOLD line where I've indicated. Should retain the current function when changing tables.

[pre]
function build_change_table_form()
// goal: build a form to choose the table
// input:
// output: the listbox
{
global $conn, $table_name, $autosumbit_change_table_control, $dadabik_main_file;

$change_table_form = '<form method="get" action="'.$dadabik_main_file.'" name="change_table_form">';
if ( $autosumbit_change_table_control == 0) {
$change_table_form .= '<input type="submit" class="button_change_table" value="'.$submit_buttons_ar["change_table"].'">';
} // end if
$change_table_form .= "<select name=\"table_name\" class=\"select_change_table\"";
if ( $autosumbit_change_table_control == 1) {
$change_table_form .= " onchange=\"javascript:document.change_table_form.submit()\"";
}
$change_table_form .= ">";

$only_include_allowed = 2;
$allowed_table_infos_ar = build_installed_table_infos_ar($only_include_allowed, 1);

$count_temp = count($allowed_table_infos_ar);
for($i=0; $i<$count_temp; $i++){
$change_table_form .= "<option value=\"".htmlspecialchars($allowed_table_infos_ar[$i]['name_table'])."\"";
if ($table_name == $allowed_table_infos_ar[$i]['name_table']){
$change_table_form .= " selected";
}
$change_table_form .= ">".$allowed_table_infos_ar[$i]['alias_table']."</option>";
} // end for
$change_table_form .= "</select>";
$change_table_form .= '<input type="hidden" name="function" value="'.$_GET["function"].'">';
$change_table_form .= '</form>';

if ($count_temp == 1 || $count_temp == 0){
return "";
} // end if
else{
return $change_table_form;
} // end else

} // end function build_change_table_form
[/pre]

Basically because this is a get form, each field in the form is appended to the URL when the form contents are submitted - in the order they appear in the form. So if you want the function to be appended before the table name, then move the line before the start of the select.

Let me know how this works out for you.
 

jake66

New member
Thank you so much Debbie - this has completely solved the problem. I think it is also quite a good addition to DadaBik so maybe something to consider next release!?

Jake :)
 
Top