Search via get Parameters

uwec

New member
DaDaBIK is 8.1

I want to add a button in the table view, that leads to a search result if clicked.

So if i Click this button :

dadabik_custom_search.png


I want to get this result:

dadabik_custom_search_result.png



Adding the Button via custom Display function is easy, but the form i added , always gets me just a redirect to the main page when i click the button.

The form for the button looks like this :

[pre]
<form method="post" action="index.php?tablename=Lager&function=search&execute_search=1&search_from_filter=1">
<input name="operator" value="and" type="hidden">
<input name="win_select_type" value="is_equal" type="hidden">
<input name="win" value="TEST 3434kk3k34k" type="hidden">
(538997)
<button class="btn btn-xs" type="submit">
<i class="fa fa-search"> </i>
</button>
</form>
[/pre]

So my questions are :

1. Am i missing something?? Need another Hidden field or whatever.
2. Is it possible to send a search simply using GET parameters in a plain link .
3. If 2 is impossible right now, maybe i could change $_POST to $_REQUEST somewhere in the core code to make it possible.

As you can see in the Images, i just want to trigger the search function of the recent table via that button.

Thanks in advance!
 

eugenio

Administrator
Staff member
Hello,
it seems a clever use of the custom display function!

There are at least a couple of issues, don't know if these are the reason:
- add enctype="multipart/form-data" to the form
- the correct field name is win__select_type (double underscore, not single).

Let me know,
 

uwec

New member
Thanks alot ! that did it !

I wrote a similar system like dadabik quite a while ago. It was based on arrays not on a backend interface as i am a coder and i don't really need a backend.

But calling a search from a table field button was quite a common practice there.

Another thing i am trying to achieve, is copying or moving an entry to another table. I make a seperate thread on this.


Thanks again !
 

uwec

New member
Just wanted to mention, that i will even function if you call it via GET parameters like :

[pre]
http://dadabik.meineseite.de/index.php?tablename=Lager&function=search&execute_search=1&search_from_filter=1&operator=and&win__select_type=is_equal&win=TEST00340303
[/pre]
 

uwec

New member
One more , it would be great it the

Custom formatting function

would get the full row data as a second parameter.
 

eugenio

Administrator
Staff member
Hello,
did you mean it works even via GET or you would like it works via GET?

About your last post: you can get all the other field values via SQL but you are right it might be useful to avoid unnecessary queries.

Best,
 

uwec

New member
I simply added the search parameters as GET parameters to the URL seemed to work perfectly on a quick test.

Like this :

[pre]
dadabik.mydomain.de/index.php?tablename=Lager&function=search&execute_search=1&search_from_filter=1&operator=and&win__select_type=is_equal&win=TEST 3434kk3k34k
[/pre]
 

eugenio

Administrator
Staff member
Hello,
are you sure it always work? It isn't designed to work in that way.

Best,
 

NorbertH

New member
I guess you where right , i forgot that i changed a line in index.php

around line 1405

i changed:
[pre]
$where_clause = build_where_clause($_POST, $fields_labels_ar, $table_name, $search_from_filter);
[/pre]
To:
[pre]
$where_clause = build_where_clause($_REQUEST, $fields_labels_ar, $table_name, $search_from_filter);
[/pre]

I made the application in quite a hurry and whithout a version controll system.

But now i can create the search links without using a form , just by plain old links.:

[pre]
$retval.= "
<a class=\"btn btn-xs\" href=\"index.php?tablename=Lager&function=search&execute_search=1&search_from_filter=1&operator=and&win__select_type=is_equal&win={$value}\">
<i class=\"fa fa-search\"> </i>
</a>
</div>
";
return $retval;

[/pre]

As its necessary to Validate any input anyway, its irrelevant if we use $_POST or $_REQUEST al teast for a simple search request.
I hope search input is escaped and validated ??
 

eugenio

Administrator
Staff member
Hello Norberth,
it might work but I cannot assure everything is working correctly, I had to check if there are other values who are expected to come from POST and/or if there could be conflicts.

Best,
 
Top