using masql field type set()

tory2307

New member
My database is developped with Mysql Workbench. I use many fields of the field type set(), the options mainly with long text sentences.
I did not find an option to use this hardcoded options in the database also in dadabik. It is only possible to hardcode the options in dadabik using the ~option 1~option 2~ etc. syntax. In one field i have a total of 18 options with each option with long sentences. It seems as if the field for the hardcoded options is too small for such an amount of text. What can i do?
 

eugenio

Administrator
Staff member
Hello,
the mysql field type ENUM is automatically translated into a select_single DaDaBIK field with hardcoded options.

The field type SET, instead, is not directly translated.

The field for the hardcoded options accepts max 100 characters so If you have 18 long sentences yes, you are right, it is probably not enough.

What you can do is editing the file /include/internal_table.php, in particular this part:

$int_fields_ar[$ar_index][0] = "Hard-coded list of the options:";
$int_fields_ar[$ar_index][1] = "select_options_field";
$int_fields_ar[$ar_index][2] = "text";
$int_fields_ar[$ar_index][3] = "100";

change 100 with whatever you need and from phpmyadmin change the field select_options_field in dadabik_forms too, if you need more than 500 chars (now it is a varchar 500).

However I don't recommend this changes to the DaDaBIK core code, also because every time you upgrade DaDaBIK you will have to edit this again. What I recommend is to use a separate lookup table containing the options, it's a cleaner solutions.

Best,
 

tory2307

New member
Hello,
next problem: even if the length of the options field is sufficient, nothing is saved to the database. You know, in a field type of set you can choose more than one option. Dadabik accepts only one (error message), and then doesn't save it in the database. With phpmyadmin it is possible wiithout problems to choose more than one option and the result shows up in the dadabik grid. After editing the dataset the set() fields are empty again. Unusable.

Best
tory2307
 

eugenio

Administrator
Staff member
Hello,
if you need to save multiple options, you have to use one of these dadabik field types:

- select_multiple_menu
- select_multiple_checkbox

the corresponding db field type must be varchar (or text if varchar is not enough) and DaDaBIK saves the values as:

~option1~option2~

the SET field is not directly supported. If you have data already saved in a SET field, you have to convert the content to the DaDaBIK format first.

Best,
 
Top