WebsiteBaker Support (2.12.x) > Modules
OneForAll - Set image to inactive won't save
dbs:
Yes.
Try this in line 489:
--- Code: --- .'SET `active` = \''.$image['active'].'\', '
--- End code ---
I think the field type in db is enum and expects a string.
CodeALot:
--- Quote from: dbs on July 11, 2019, 11:32:15 AM ---Yes.
Try this in line 489:
--- Code: --- .'SET `active` = \''.$image['active'].'\', '
--- End code ---
I think the field type in db is enum and expects a string.
--- End quote ---
In the table definition it says:
active enum('1', '0') utf8_general_ci
But your solution worked! Thanks a lot!
jacobi22:
i think, the "secret" and the different is the MYSQL-Version - but i'm not sure, that i understand everything correct here -> https://dev.mysql.com/doc/refman/8.0/en/enum.html
i understand: if i use a unmasked number, it works as an index from the enum-field -
submitted 1 == index(1) = in this case: 1
submitted 2 == index(2) = in this case: 0
and a masked value (like \''.$image['active'].'\') is the value like 1 or 0
may and hope, Manu or Dietmar can help, because OFA and Bakery are full of enum-fields like this
CodeALot:
The weird thing is that it DID work if you had an INactive image and you set it to Active, it would save correctly.
Only setting it back to INactive was not saved...
jacobi22:
if you activate the checkbox for image-activity, you submit a "1", but if you not activate this checkbox, you submit nothing (for this activity-setting) - thats the result, if you use 1 or 0 in a checkbox (also in a radio-button)
(If you use instead of 1 or 0 - now 1 or 2, you submit a result in every case, but it needs one or two lines more in the code of save_image.php)
next part is the save_image - the same procedure....
if the field "image_active" == empty (means: nothing submitted), set the Value to 0
if it's not empty (means: something submitted, no matter, what), set it to 1
now, we have a numeric value like 1 or 0. in older mysql-version's it doesn't matter, what kind of type you have, integer or string, maybe important, if you use MYSQL-STRICT, i've not test it.
but in the newer version, you can submitted this value as string (like post from dbs) or as numeric index
for example: you use a enum-field like enum('Berlin','Paris','London')
a submitted 1 as integer is here == Berlin, because 'Berlin" is the first definition (or Index) in the field definition), a submitted 3 is == London, a submitted 4 == nothing, because, you have only 3 indizes, not 4 - #4 is invalid). if you have "nothing", use the default value or (if not defined) do nothing
back to OFA
definition of this database field: enum('1','0') default '1'
Index 1 == 1
Index 2 == 0
but you submit not valid index, you submit index == 0. And if you submit a invalide index, it use the default value == 1
Solution from dbs submitted a string ( not the number of the index like my first solution), that's why it works also with 0
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version