Other choices allowed?

nassausky

Member
[pre]
You are using DaDaBIK version 6.2 ENTERPRISE
You are runnning the last release of DaDaBIK
PHP Version: 5.3.29
mysql version: 5.5.32-31.0-log
Web server: Apache
Client: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
[/pre]

I wanted to allow other choices (user to add something) but NOT have it added to the Hard-coded list of the options for the future.
I am guessing I will have to edit the PHP code, Anybody know where to look or how to do it?

Thanks
 

eugenio

Administrator
Staff member
Hello,
you could do that but then you will be not able to show the value because DaDaBIK won't find it in the list of options, can you explain better what is the use case for this need?

Best.
 

nassausky

Member
I am making an event manager which includes a field for custodial setup. They need to fill it between 3 or 4 fields most of the time.
Choices are:
[pre]
N/A
Typical
No-Setup
other....
[/pre]


They have a chart for most setups but there are times that they need to type in a line.
For example other options would be:
[pre]
3 tables in a U,
2 tables covered
podium, speakers, classroom setup
audio system, microphone, fans
[/pre]

Not limited to the above, I don't want that list to accumulate and I don't want to keep removing the extra items manually.

Thanks
 

nassausky

Member
in 6.2 ENTERPRISE can you direct me to

Where it adds it into the field

and maybe

Where it only allows the list values.

Thanks :)
 

eugenio

Administrator
Staff member
The insertion of the new option is in two functions
insert_other_field (if the options come from a table)
update_options (if the options are hard-coded)

The hard part is when you show the edit form (build_form), because it assumes a list of registered options.

Details page and results page work probably (I haven't checked it) fine.
 

nassausky

Member
Yes, sorry I got it 2 days ago and didn't post the code yet.

I emptied the code in the insert_other_field. (This was good in my case since I don't want anyone adding anything into any 'other....' text boxes).

I also found the location to display the current value underneath the drop down list. Like you said it didn't show the current value in the update form when I cleared out the insert_other_field function but it did show in the details page and search/browse page, so with my added code the user can now see the current value on the update page as well as the detail and search/browse pages if they want to make any changes.


Thanks again

Me said:
if you try hard enough you can do anything you set your mind to, maybe not perfect but usually good enough to make yourself happy. :)
 

nassausky

Member
The time limit to edit messages in this forum must be too short. I went right back to edit the previous message for clarification but the forum wouldn't let me change it and said there was a time limit. I did it very fast so my guess is the time limit for me to make a correction is very short.

With my added code the user can now see the current value on the update page as well as the detail and search/browse pages. Now they can choose from the drop down list and add an other option but that other option won't be permanent. :)

I will have to dig through my code and see if I can paste the code here if anyone else is interested.


Thanks
 

nassausky

Member
OK here is how I got it to work. (You can add values to the other... choice in drop down lists and not have them saved)

Both in business_logic.php

I didn't touch the insert_other_field function but instead removed the update_options function as below

[pre]
function update_options($fields_labels_ar_i, $field_name, $field_value_other)
// goal: upate the options of a field when a user select other....
// input: $fields_labels_ar_i (fields_labels_ar specific for a field), $field_name, $field_value_other
{
/*
Code in this function is only necessary if you want to keep any or all of your extra other field values.
*/
} // end function update_options($fields_labels_ar_i, $field_name, $field_value_other)
[/pre]



In the same file business_logic.php

Look for At the end of the if statement deep down inside the function build_form:
[pre]
if ($fields_labels_ar[$i]["other_choices_field"] == "1" and ($form_type == "insert" or $form_type == "update" )){
...code...

$sqlf= "SELECT `".$field_name_temp."` FROM items WHERE ItemNum=".$where_value;
$resf = execute_db($sqlf, $conn);
$resultf=$resf->fetch(PDO::FETCH_ASSOC);

$form .= ">"; // text field for other....
} // end if
$form .= "</div>";
$form .= $resultf[$field_name_temp]; //This displays the value of the dropdown list even if it's not saved in the choices
[/pre]
 

eugenio

Administrator
Staff member
Hello,
thanks for sharing it, I haven't checked in details your code but there is probably a few problem with search, you can't search for the "not saved" options.
 

nassausky

Member
I will have to keep that in mind. Right now I have no need to search for Custodial Setup details but when i get time maybe I will try to see how I can overcome that issue if I decide to use other drop down lists the same way.

Thanks
 
Top