Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Framework » DropDown Field values - changing in runtime
DropDown Field values - changing in runtime [message #7678] Thu, 10 February 2022 06:51 Go to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Hi Tony,

I have a DropDown field which works fine. The values of this DropDown field are generated by fields in the same record. These fields are the foreign key of the table where the values come from. After changing the value of these (foreign key) fields with a popup pattern I have to submit and open the record again before I get the new (right) values for the DropDown field.

Can I change the values for the DropDown field in the _cm_popUpReturn() method or somewhere else by calling the _cm_getExtraData() method again? Or is there another way?

For your understanding: In the record are sizes stored depending of dressing type. Shoes (8, 8 1/2, 9, 12, ...) have other sizes as clothes (S, L, XXL, ..). And I want to have the right values for the different types.
Re: DropDown Field values - changing in runtime [message #7679 is a reply to message #7678] Sat, 12 February 2022 04:22 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
It is possible to automatically submit a form whenever the uses chooses an option in a dropdown list. Take a look at the following:
I use this in my ERP application with great success.


Re: DropDown Field values - changing in runtime [message #7680 is a reply to message #7679] Mon, 14 February 2022 04:30 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
I added the following code in _cm_changeConfig():

if ($GLOBALS['task_id'] == 'htm_orga_mannschaften_ausruestung_kontakte(add2)') {
// insert some javascript to submit form when a different value is selected in this dropdown list
$this->fieldspec['gr_art']['javascript'] = array('onchange' => 'this.form.submit();');
} // if

Is it right that the following code in the _cm_setJavaScript() method should call the _cm_updateFieldArray() method? Or will the form be sent to the server directly? Because the _cm_updateFieldArray() method will not be called in my class.

// specify javascript events on certain fields
if ($mode == 'insert' or $mode == 'update') {
$this->fieldspec['gr_art']['javascript'] = array('onchange' => 'this.form.submit();');
} // if
Re: DropDown Field values - changing in runtime [message #7681 is a reply to message #7680] Tue, 15 February 2022 07:09 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
Please follow the sample code in Example of 'submit()' function where the javascript is set in the _cm_changeConfig() method. Whenever the 'onchange' trigger on this field is fired it will automatically submit the form to the server, and this will cause the _cm_updateFieldarray() method to be fired.

Re: DropDown Field values - changing in runtime [message #7682 is a reply to message #7681] Wed, 16 February 2022 04:08 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Sorry, my fault. I didn't explain it right.

I have a foreign (compound) key in my table and I call a popup form to choose an occurence of this foreign table. In _cm_getExtraData() I have the code for filling the dropDown list with the values of a table consisting of the foreign key and another key field with the (detail) values I want.

As far as I understand, the popupReturn event doesn't fire an 'onchange' trigger and that's why the _cm_updateFieldarray() method will not be fired.

Using a dropdown field for a compound key as desribed in FAQ 138 was the last time too difficult for me. But I will try it again.

It is possible to fire an 'onchange' trigger in the _cm_popupReturn() method after filling in the selected values in $fieldarray? Or is there a better solution for this problem?

[Updated on: Wed, 16 February 2022 06:57]

Report message to a moderator

Re: DropDown Field values - changing in runtime [message #7683 is a reply to message #7682] Wed, 16 February 2022 17:37 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
As you described in FAQ 138 I could get the primary key values and insert them in $fieldarray. Through this I could generate the array with the values for the second dropdown in _cm_updateFieldarray(). But now I don't know how to fill the dropdown list with these values. Is this possible at all in this method?
Re: DropDown Field values - changing in runtime [message #7684 is a reply to message #7683] Thu, 17 February 2022 04:28 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
The 'onchange' trigger will not fire the popupReturn() event, but it will fire the updateFieldArray() event. If you have some code in the popupReturn() event that you want executed in the updateFieldArray() event then you should put this code insto a sub-function which you can then call from both events.

Re: DropDown Field values - changing in runtime [message #7685 is a reply to message #7684] Fri, 18 February 2022 06:18 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
How can I populate the lookup_data array in _cm_updateFieldarray()?

$this->lookup_data['foo_bar'] = $array; doesn't work.

Is there something I have to take care of?
Re: DropDown Field values - changing in runtime [message #7686 is a reply to message #7685] Fri, 18 February 2022 07:07 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
If I step through the code with the debugger I see that the _cm_getExtraData() method is called again and that's why one of the key fields which I need for the second dropdown field is filled again with the 'compound key string'. For this reason the values for the second dropdown field can not be selected because the key isn't right. I try to find a solution for this problem now.
Re: DropDown Field values - changing in runtime [message #7687 is a reply to message #7686] Fri, 18 February 2022 10:17 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
I found a solution. I inserted an additional field with the control dropdown. This field holds the string with the compound key. After changing this new dropdown field the updateFieldArray() method is fired and I stored the primary key values for my 2nd dropdown list in $GLOBALS. In the _cm_getValRep() method of this class I could insert these values in my query. Everything works fine at the moment. Just as I wanted. Hopefully without problems in other patterns...
Re: DropDown Field values - changing in runtime [message #7688 is a reply to message #7685] Sat, 19 February 2022 04:56 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
If the contents of $this->lookup_data['foo_bar'] needs to change depending on a selection which you have made in a dropdown list then you need to rebuild the contents of $array in the _cm_updateFieldarray() method by retrieving data using this selection as an argument.

Any code you have in the _cm_getExtraData() method should not rebuild the contents of $this->lookup_data['foo_bar'] if it already exists.


Re: DropDown Field values - changing in runtime [message #7690 is a reply to message #7688] Sat, 05 March 2022 04:48 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
If I change the value in the dropdown list the value of a numeric field will be increased by a factor of 100. From 50,00 to 5000,00 and so on, each time I change the dropdown field value. In the $postarray in _cm_updateFieldArray() the value is still correct. Seems to come from the comma ',' instead of the '.'. Do I have to change something in $fieldspec in _cm_changeconfig() or somewhere else?
Re: DropDown Field values - changing in runtime [message #7691 is a reply to message #7690] Sun, 06 March 2022 04:57 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
I do not understand the question. How is this column defined in the $fieldspec array? What are the contents of $this->lookup_data['column']? When you change the value in the screen and the submit() event is triggered what values appear in the updateFieldArray() method?

Re: DropDown Field values - changing in runtime [message #7692 is a reply to message #7691] Sun, 06 March 2022 06:01 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
This is the definition of the column:

$fieldspec['ma_ausruestung_preis_eigenanteil']= array('type' => 'numeric',
'size' => 12,
'precision' => 11,
'scale' => 2,
'minvalue' => 0,
'maxvalue' => 999999999.99,
'default' => '0.00');

If I set $this->fieldspec['ma_ausruestung_preis_eigenanteil']['noedit'] = 'y' in _cm_changeConfig() everything works fine and the value will not be increased.

This is the content of $postarray and $fieldarray in _cm_updateFieldArray()

C:\xampp\htdocs\radicore\htm\classes\orga_mannschaften_konta kte_ausruestung.class.inc:732:
array (size=8)

this is the composed value from the lookup table, existing of the three foreign key values
'gr_art_dropdown' => string '&SCH-DE&D&1' (length=11)

'gr_art_ausr' => string 'S' (length=1)
'ma_ausruestung_ausgabe' => string 'on' (length=2)
'ma_ausruestung_ausgabe_datum' => string '2022-02-19' (length=10)

this is the value which will be increased to 5000.00, 500000.00, 50000000.00, .... each time I change the dropdown field value
'ma_ausruestung_preis_eigenanteil' => string '50.00' (length=5)

'ma_ausruestung_preis_eigenanteil_bezahlt' => string 'on' (length=2)
'ma_ausruestung_preis_eigenanteil_bezahlt_datum' => string '2022-02-19' (length=10)
'ma_ausruestung_trikot_no' => string 'EA' (length=2)

C:\xampp\htdocs\radicore\htm\classes\orga_mannschaften_konta kte_ausruestung.class.inc:733:
array (size=39)
'verbaende_art_id' => string 'LV' (length=2)
'verbaende_kuerzel' => string 'HV S' (length=4)
'vereine_kuerzel' => string 'HVS' (length=3)
'saison_id' => string '2021/2022' (length=9)
'mannschaften_id' => string '2007W' (length=5)
'user_id' => string 'HVS' (length=3)
'user_seq_no' => string '2' (length=1)
'ausruestung_id' => string 'TSHIRT' (length=6)
'ausruestung_anr' => string '2007W-SC-HVS' (length=12)
'rdcaccount_id' => string '7' (length=1)
'ma_ausruestung_kontakt_name' => string 'Alizada' (length=7)
'ma_ausruestung_kontakt_vorname' => string 'Emilia' (length=6)
'ma_ausruestung_marke' => string 'Adidas' (length=6)
'ma_ausruestung_modell' => string 'T 4711' (length=6)
'ma_ausruestung_desc' => string 'T-Shirt Sommercamp 2021 - 2007w' (length=31)

this is the value from the lookup table
'gr_art_dropdown' => string '&KLD-DE&D&1' (length=11)

these are the foreign keys values coming from 'gr_art_dropdown'
'gr_art' => string 'KLD-DE' (length=6)
'gr_art_sub' => string 'D' (length=1)
'gr_art_rdc' => string '1' (length=1)

'gr_art_ausr' => string 'S' (length=1)
'ma_ausruestung_farbe' => string 'rot' (length=3)
'ma_ausruestung_farbnummer' => null
'ma_ausruestung_preis_netto' => string '0.00' (length=4)
'ma_ausruestung_preis_rabatt' => string '0.000' (length=5)
'ma_ausruestung_preis_rabatt_berechnen' => string '0' (length=1)
'ma_ausruestung_preis_mwst' => string '0.00' (length=4)
'ma_ausruestung_preis_mwst_berechnen' => string '0' (length=1)
'ma_ausruestung_preis_brutto' => string '0.00' (length=4)

this is the value which will be increased to 5000.00, 500000.00, 50000000.00, .... each time I change the dropdown field value
'ma_ausruestung_preis_eigenanteil' => string '50.00' (length=5)

'ma_ausruestung_preis_eigenanteil_bezahlt' => string '1' (length=1)
'ma_ausruestung_preis_eigenanteil_bezahlt_datum' => string '2022-02-19' (length=10)
'ma_ausruestung_preis_berechnen' => string '0' (length=1)
'ma_ausruestung_pfad_bild' => null
'ma_ausruestung_pfad_video' => null
'ma_ausruestung_barcode' => null
'ma_ausruestung_trikot_no' => string 'EA' (length=2)
'ma_ausruestung_ausgabe' => string '1' (length=1)
'ma_ausruestung_ausgabe_datum' => string '2022-02-19' (length=10)
'ausruestungs_groesse_art_desc' => string 'Kleider-Größen Damen (EU/DE)' (length=30)
Re: DropDown Field values - changing in runtime [message #7694 is a reply to message #7692] Wed, 09 March 2022 04:36 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
According to your sample code the column with the dropdown list is 'ma_ausruestung_preis_eigenanteil', but you have not shown the contents of $this->lookup_data['ma_ausruestung_preis_eigenanteil']. This is an associative array, so I am interested in seeing the keys and the values. You have also not explained how the column 'gr_art_dropdown' fits into the picture. Where is the code which splits your multi-part value into a series of separate values?

[Updated on: Wed, 09 March 2022 04:37]

Report message to a moderator

Re: DropDown Field values - changing in runtime [message #7695 is a reply to message #7694] Wed, 09 March 2022 05:09 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Sorry for my English and how I try to explain what I mean.

The field gr_art_dropdown ('Größe (Art) auswählen')is a field with a dropdown list. It will be filled with the description of the size categories (shoes, cloths, etc.).
The field gr_art_ausr ('Größe') is the field where you can choose the right size of the chosen category.
The field ma_ausruestung_preis_eigenanteil ('Eigenanteil') is the field which holds the part of the total cost which will be payed by the team member.

I added two screen shots: the initial and a changed one. Hopefully you can see what I tried to explain. I added the code of the _cm_getValRep() method of the table from where the values come.

In the screenshot you see in 'Größe (Art) auswählen' the category of the size (shoes, cloth, etc.). And in 'Größe' the selectable values. In 'Eigenanteil' you see the value of the money (50.00, 5000,00).
In the green circle you can see the individual values of the compound foreign key which identify the key for filling the field 'Größe' with the right values.

// ************************************************************ ****************
function _cm_getValRep ($item=null, $where=null, $orderby=null)
// get Value/Representation list as an associative array.
{
$array = array();

switch ($item) {

case 'groessen_art_ausr_kopf' :

// get data from the database
$this->sql_select = 'gr_art, gr_art_sub, rdcaccount_id, ausruestungs_groesse_art_desc';

$this->sql_orderby = 'ausruestungs_groesse_art_desc';
$this->sql_ordery_seq = 'asc';

$data = $this->getData($where);

// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {

$key = '&' . $rowdata['gr_art'] . '&' . $rowdata['gr_art_sub'] . '&' . $rowdata['rdcaccount_id'];
$array[$key] = $rowdata['ausruestungs_groesse_art_desc'];

} // foreach

return $array;

case 'groessen_art_ausr_detail' :

// ermittelt den Primärschlüssel

if (isset($GLOBALS['gr_key_array'])) {
$primary_key_values = $GLOBALS['gr_key_array'];
} else {

$primary_key_values['1'] = $GLOBALS['fieldarray']['gr_art'];
$primary_key_values['2'] = $GLOBALS['fieldarray']['gr_art_sub'];
$primary_key_values['3'] = $GLOBALS['fieldarray']['gr_art_rdc'];
}

// get data from the database
$this->sql_select = 'orga_groessen_ausr_detail.gr_art_ausr, orga_groessen_ausr_detail.argroesse_desc';

$this->sql_from = "orga_groessen_ausr " .

" LEFT JOIN orga_groessen_ausr_detail ON (" .

"orga_groessen_ausr_detail.gr_art = orga_groessen_ausr.gr_art AND " .
"orga_groessen_ausr_detail.gr_art_sub = orga_groessen_ausr.gr_art_sub AND " .
"orga_groessen_ausr_detail.rdcaccount_id = orga_groessen_ausr.rdcaccount_id)";

$this->sql_orderby = 'argroesse_desc';
$this->sql_ordery_seq = 'asc';

$where = "gr_art = '{$primary_key_values['1']}' AND " .
"orga_groessen_ausr_detail.gr_art_sub = '{$primary_key_values['2']}' AND " .
"orga_groessen_ausr_detail.rdcaccount_id = '{$primary_key_values['3']}'";

$data = $this->getData($where);

// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {

$rowvalues = array_values($rowdata);
$array[$rowvalues[0]] = $rowvalues[0] . ' - ' . $rowvalues[1];

} // foreach

return $array;

} // switch

return $array;

} // _cm_getValRep

[Updated on: Wed, 09 March 2022 09:03]

Report message to a moderator

Re: DropDown Field values - changing in runtime [message #7696 is a reply to message #7695] Fri, 11 March 2022 06:03 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
I do not want to see how you construct the contents of each dropdown list in $this->lookup_data['...'], I want to see the actual contents. Then I want to see the code which is executed whenever you change a value in one of the dropdown lists in the screen. I want to see how you split the compound key into its component parts and then what you do with each of those parts.

You originally described your problem as follows: Quote:
If I change the value in the dropdown list the value of a numeric field will be increased by a factor of 100. From 50,00 to 5000,00 and so on
Are you saying that your code increases the value of this numeric field by a factor of 100 when it should not? You need to show the the code which you are using and highlight the place where it is producing the wrong result.


Re: DropDown Field values - changing in runtime [message #7697 is a reply to message #7696] Fri, 11 March 2022 09:53 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
I split the compound key into its component parts in _cm_updateFieldArray() with the following code:

$str_gr_art = $postarray['gr_art_dropdown'];

if (isset($postarray['gr_art_dropdown'])) {
$gr_key_array = explode('&', $str_gr_art);

// weist die Daten $GLOBALS zu
$GLOBALS['gr_key_array'] = $gr_key_array;

// liest die Schlüsselwerte der ausgewählten Größe ein
$fieldarray['gr_art'] = $gr_key_array[1];
$fieldarray['gr_art_sub'] = $gr_key_array[2];
$fieldarray['gr_art_rdc'] = $gr_key_array[3];

// ermittelt die Größen-Werte aus orga_groessen_ausr_detail
$dbobject =& RDCsingleton::getInstance('orga_groessen_ausr_detail'); // Instanz für Lookup-Tabelle

$dbobject->sql_select = 'gr_art_ausr, argroesse_desc';

$where = "gr_art='{$fieldarray['gr_art']}' AND " .
"gr_art_sub='{$fieldarray['gr_art_sub']}' AND " .
"rdcaccount_id='{$fieldarray['gr_art_rdc']}'";

// sortiert die Daten
$dbobject->sql_orderby = 'argroesse_desc';
$data = $dbobject->getData ($where);

// weist die Werte der Lookup-Variablen zu
foreach ($data as $row => $rowdata) {

$rowvalues = array_values($rowdata);
$array[$rowvalues[0]] = $rowvalues[0] . ' - ' . $rowvalues[1];

} // foreach
}

But the code is in my opinion not the problem. The numeric field has the same behaviour even if I set the above code in /* */

If I change the value of the numeric field before changing the dropdown field from 50,00 to 50,0, the numeric field will be increased to 500,00. If I change the value to 5 the value will not be increased but changed to 5,00. 5,0000 will be changed to 50.0000,00 and so on.
Changing the value of the numeric field to 5.00 (. instead of ,) increases the value by the factor of 100 and so on..

If I delete the code "$this->fieldspec['gr_art_dropdown']['javascript'] = array('onchange' => 'this.form.submit();');" in _cm_changeConfig(), nothing happens, the numeric field doesn't change the value.

[Updated on: Sat, 12 March 2022 09:18]

Report message to a moderator

Re: DropDown Field values - changing in runtime [message #7698 is a reply to message #7697] Mon, 14 March 2022 05:41 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
You really need to learn how to debug your code. If you don't have an IDE with a symbolic debugger then you should put some echo statements into you code to display what values are appearing in your variables.

I spotted one mistake straight away - after you unpack the string into an array with
$gr_key_array = explode('&', $str_gr_art);
you reference the three parts with indexes [1], [2] and [3]. This is wrong as the array starts with index [0].


Re: DropDown Field values - changing in runtime [message #7699 is a reply to message #7698] Tue, 15 March 2022 07:58 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Sorry about the circumstances, but I use Eclipse IDE and I echo the values for proofing. In this case the value for array[0] is ''. And the values I need are in the arrays [1], [2] and [3].

You told me in earlier posts that I only should examine my own code. That's what I did. You are right that I am not that familiar with working with a debugger. Stepping through all your code, line by line is very time consuming and I don't exactly know what I am looking for to see where the value of my numeric field will be changed in the way I described. Can it be that this is a problem with the different spelling of numeric values in England and Germany? "1,000.00" instead of "1.000,00"?
Re: DropDown Field values - changing in runtime [message #7700 is a reply to message #7699] Wed, 16 March 2022 05:48 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
The only way to get an empty string in array[0] is if your string contains the '&' delimiter at the very start, as in '&one&two&three' when the normal practice would be to use 'one&two&three'.

When debugging a problem the first place to look is always a custom method which contains code which you have written. You need to look at the input values to see if they are correct and then the output values to see if they are correct. You need to identify the code which is producing the wrong result, then examine the execution of that code line by line with your debugger to see exactly where it is producing the wrong result.

You keep trying to describe what is going wrong, but unless I can run the actual code which you are using and duplicate the error I will never be able to fix it..


Re: DropDown Field values - changing in runtime [message #7701 is a reply to message #7700] Wed, 23 March 2022 05:46 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
In https://www.tonymarston.net/php-mysql/functions-and-variable s.html#sequence.of.events under updateFieldArray() the sequence of events is:

1. _cm_updateFieldArray ($fieldarray, $postarray, $rownum)
2. _cm_commonValidation ($fieldarray, $postarray)
3. getExtraData ($fieldarray)

I use German as my default browser language. The value in my numeric field is shown as "50,00".

In _cm_updateFieldArray() I have the following values:
$postarray['ma_ausruestung_preis_eigenanteil'] = "50.00".
$fieldarray[''ma_ausruestung_preis_eigenanteil'] = "50.00".

In _cm_commonValidation() I have the following values:
$fieldarray[''ma_ausruestung_preis_eigenanteil'] = "5000".
$originaldata['ma_ausruestung_preis_eigenanteil'] = "50.00".

Is the value in $fieldarray in _cm_commonValidation correct because of the different language spellings and notations?
Re: DropDown Field values - changing in runtime [message #7702 is a reply to message #7701] Thu, 24 March 2022 06:54 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
All decimal values, both within PHP and the database, use the same format - decimal point is '.' with no thousands separator. This means that five thousand is held as '5000.00'. When displayed this is converted to '5,000.00' for the UK and '5.000,00' for Germany. When using dropdown lists to provide choices for the user this list is an array of entries with a key and a value. The key is used internally in the code while the value can change according to the user's language. The framework does not automatically convert any decimal values used as keys between internal and external format for the simple reason that keys are never displayed to the user, only the values. I cannot see why the value in $fieldarray['ma_ausruestung_preis_eigenanteil']is being changed from '50.00' to '5000' as I am unable to duplicate this problem on my PC as you have yet to provide me with the actual code that you are using. All you keep doing is provide descriptions of the code which is not enough. I need to see the exact contents of the dropdown list, not a description of how you build it.

If you have spotted that the value is being changed somewhere after the call to _cm_updateFieldArray() and before the call to _cm_commonValidation() then that is where you need to step through with your debugger to see precisely where the value is being changed.


Re: DropDown Field values - changing in runtime [message #7703 is a reply to message #7702] Thu, 24 March 2022 12:46 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
The framework calls the method number_unformat() in include.libary.inc two times.

The first call with value 50,01 is fine. The $decimal_point is empty and will be filled with $GLOBALS['localeconv']['decimal_point'] = ',' and the $thousands_sep will be filled with $GLOBALS['localeconv']['thousands_sep'] = '.'.
$number has now the value 50.01.

After this, my Debugger steps to _cm_updateFieldArray() and once more to number_unformat() with the (changed) value 50.01. In line 5776 the '.' in the number will be replaced with ''.

Is this behaviour of the framework right or do I have to search in my code for the problem?
Re: DropDown Field values - changing in runtime [message #7704 is a reply to message #7703] Fri, 25 March 2022 06:48 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
I have changed the code so that during the processing of the updateFieldarray() method it calls the number_unformat() function only once. I also found and fixed a problem when converting dates from external to internal format.

The two scripts which I changed are in the attached zip file. Please try these out and tell me if they fix the problem.


Re: DropDown Field values - changing in runtime [message #7705 is a reply to message #7704] Fri, 25 March 2022 07:28 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Thank you very much. Works fine now.
Re: DropDown Field values - changing in runtime [message #7706 is a reply to message #7705] Sat, 26 March 2022 06:18 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
After a bit more testing I found a bug in one of those scripts which I changed, so I attach a new zip file which fixes that bug.

Re: DropDown Field values - changing in runtime [message #7707 is a reply to message #7706] Mon, 28 March 2022 06:30 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Thank you. Yes I also had one exception with the changed scripts in includes.library.inc with DateTime().
Re: DropDown Field values - changing in runtime [message #7708 is a reply to message #7707] Fri, 01 April 2022 09:59 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
Was that fixed with the second update I gave you, or is it still there?

Re: DropDown Field values - changing in runtime [message #7709 is a reply to message #7708] Sat, 09 April 2022 09:01 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
The second fix works fine. Until now I had no more exceptions.
Re: DropDown Field values - changing in runtime [message #7710 is a reply to message #7709] Sun, 10 April 2022 03:17 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
The words "Until now I had no more exceptions" implies it covers the period up to and including "now". What about since now? Are you getting any more errors, or have they all been fixed?

Re: DropDown Field values - changing in runtime [message #7711 is a reply to message #7710] Tue, 12 April 2022 15:07 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Sorry, I hadn't had that much time in the last days to work on it. I inserted and changed some records and everything works fine.
Re: DropDown Field values - changing in runtime [message #7713 is a reply to message #7711] Wed, 13 April 2022 04:47 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
That's good news.

Re: DropDown Field values - changing in runtime [message #7877 is a reply to message #7713] Thu, 24 October 2024 12:28 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Do you have any ideas or suggestions where I can check which field gets focus next when I have a value selected and press Tab or Enter?

And can I trigger the dropdown box when opening/changing a record?
When inserting a new record, this is done by: $this->fieldspec['foo_bar']['javascript'] = array('onchange' => 'this.form.submit();');


Re: DropDown Field values - changing in runtime [message #7881 is a reply to message #7877] Wed, 13 November 2024 05:07 Go to previous message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
It is not possible using pure HTML to identify which is the next field to get focus. Information from the current screen is not sent to the script running on the server until a SUBMIT operation is activated. The position of the cursor is unknown, so the next field to get focus is also unknown.

Previous Topic: Changing screen look
Next Topic: Importing default values -> enclosed in quotes
Goto Forum:
  


Current Time: Mon Nov 18 03:47:36 EST 2024

Total time taken to generate the page: 0.02896 seconds