Populate a drop-down list at the fly

QuestionsPopulate a drop-down list at the fly
Massimo Gagliardi asked 11 years ago

I have a table with many values ​​from a drop-down list (payment methods, types of document, vectors, seasons, …)
It may happen that when you are in the advanced editing of a new record we realize that a given value in a drop-down list is missing.
You need to let the update, go to the related table to add the missing value and, finally, back into the original table and restart the upgrade from the beginning.
I would like there was a button, next to the dropdown list, like the calendar widget, which can open a form to update the related table and back on the main form with the dropdown menu up to date.
Is it a dream?
Thanks for any suggestions

3 Answers
Abu Ghufran answered 11 years ago

I think, the easiest solution would be to have a fixed value in dropdown: like

$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
$col["editoptions"] = array("value"=>":;-1:New Payment Method;".$str);
$col["editoptions"]["onchange"] = "function(o){ check_payment_dropdown(o); };

<script>
function check_payment_dropdown(o)
{
if (o.value == -1)
window.open('my-new-payment-method-form.php');
}

This would work when you have simple (non-dependent) dropdowns.

Massimo Gagliardi answered 11 years ago

I think to a function in the add or edit dialog not in the inline edit.
It's possibile in the dialog?

Abu Ghufran answered 11 years ago

Hello Again,

It may need some core level changes and currently it is not supported.
Adding it in todos for review.

Your Answer

18 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?