Custom Button on specific field of Insert and Edit form possible?

jason

New member
Is it possible to add a button beside a field on the edit and insert forms?

I have a form that has a lookup table "City". In the form when the user is inserting or editing, if the city they are looking for doesn't exist in the lookup table, I want a button to appear next to it they can click to add the city to the city lookup table.

Is this possible?

Example of what I mean:
AddCity.jpg


---------------------------------------------------------
Your current DaDaBIK version:

You are using DaDaBIK version 10.1-Manarola enterprise, installed on 05-15-2020 (installation code: 155165ebef2d6ed236), the latest version of DaDaBIK is 10.1-Manarola released on 03-09-2020

You are runnning the last release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enteprise to Platinum) please contact us.
System info

PHP Version: 7.2.30

mysql version: 5.6.47-cll-lve

Web server: Apache

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
 

jason

New member
I can see the 'position_form' item but I can't seem to get custom buttons to appear at all.

In custom_functions.php I have the following code:

// CUSTOM BUTTONS
$cnt = 0;
$custom_buttons['LUT_CITIES'][$cnt]['type'] = 'php_standard';
$custom_buttons['LUT_CITIES'][$cnt]['callback_function'] = 'dadabik_edit_cities';
$custom_buttons['LUT_CITIESs'][$cnt]['permission_needed'] = 'none';
$custom_buttons['LUT_CITIES'][$cnt]['show_in'][] = 'insert_form';
$custom_buttons['LUT_CITIES'][$cnt]['position_form'] = 'FK_CITY_ID';
$custom_buttons['LUT_CITIES'][$cnt]['label_type'] = 'fixed';
$custom_buttons['LUT_CITIES'][$cnt]['label'] = 'Edit Cities';
$custom_buttons['LUT_CITIES'][$cnt]['style'] = 'background:#000;width:200px';
$cnt++;
/* add custom buttons here (see documentation for details) */
-------------------------------------------------------
custom_buttons.php I have:
function dadabik_edit_cities($table_name)
{

// let's go to the edit agecies page
header('Location:'.$dadabik_main_file.'?function=search&tablename='.urlencode($table_name));

exit;
}
--------------------------------------------------------
In config.php I have
// Enable the use of custom button functions in a DaDaBIK application (0|1)
$enable_custom_button_functions = 1;
---------------------------------------------------------
but still no button appearing on the insert form.

With: $custom_buttons['LUT_CITIES'][$cnt]['position_form'] = 'FK_CITY_ID';
In this example, is 'LUT_CITIES' the table name the form is based on or the page name?
Is 'FK_CITY_ID' the field name or the field label?

What am I doing wrong? I can't get custom buttons to appear at all, even with
$custom_buttons['LUT_CITIES'][$cnt]['position_form'] = 'top';
 

eugenio

Administrator
Staff member
Hello,
I haven't checked all the code but I see you have a typo here:

LUT_CITIESs

That could be one of the reasons.

Best,
 

jason

New member
Thanks Eugenio, that typo was not in the actual code, I must have added it when I pasted it in the forum.

Anyhow, I saw that there was another user post about custom buttons not appearing and the user reported the next day they just started working. The same thing happened for me. My code didn't change, just the buttons are appearing today.

Is there a cache of some kind that could be causing this? I tried closing and reopening the browser and the buttons wouldn't appear the other day, but today they are there.

Jason
 

jason

New member
I discovered it was a custom .css in styles_screen_custom.css that was not allowing the button to render properly.

The style of the button is .form_input_element_button
 

larryk

Well-known member
Hi Jason,

Wanted to ask if you got the button to display and function like you needed? I'm looking to do something similar :)


Also, by chance, have you had a need to display dynamic text on a form page? without that text being tied to a database field?

thanks
 
Top