Get the selected value of a field in a customized form
-
Hello! It’s me again…
I’m trying to customize the form of the table that is generated with the following code in SQL:
CREATE TABLE
pruebaese
(
MES
varchar(20) NOT NULL COMMENT ‘Mes’,
CLIENTE
varchar(50) NOT NULL COMMENT ‘Clientes’,
SUB-CLIENTE
varchar(50) DEFAULT NULL COMMENT ‘Sub-Cliente’,
ID
int(11) NOT NULL AUTO_INCREMENT COMMENT ‘ID’,
CODIGO-RODI
varchar(20) NOT NULL COMMENT ‘Codigo Rodi’,
NOMBRE
varchar(70) NOT NULL COMMENT ‘Nombre del Candidato’,
PROGRESO
enum(‘1.- Recepcion de Informacion’,’2.- Contacto con el Candidato’,’3.- Agendada Entrevista/Visita Domiciliaria’,’4.- Realizada Entrevista/Visita Domiciliaria’,’5.- Referencias Laborales en Proceso’,’6.- Captura y Redaccion’,’7.- Entregado’,’-‘) NOT NULL COMMENT ‘Progreso Especifico’,
STATUS
enum(‘En Proceso’,’Detenido’,’Cancelado’,’Terminado’,’-‘) NOT NULL COMMENT ‘Status’,
CONTACTO
enum(‘Si’,’No’) NOT NULL COMMENT ‘Contacto con el Candidato’,
FECHA-CITA
date DEFAULT NULL COMMENT ‘Fecha de Cita Programada’,
HORA-CITA
time DEFAULT NULL COMMENT ‘Hora de Cita Programada’,
REALIZO-VISITA
enum(‘Si’,’No’,’N/A’) NOT NULL COMMENT ‘Se Realizo Visita’,
OBTUVIERON-REFERENCIAS
enum(‘Si’,’No’,’N/A’) NOT NULL COMMENT ‘Se Obtuvieron Referencias Laborales’,
STATUS-ESPECIFICO
text COMMENT ‘Status Especifico’,
FECHA-ENTREGA
date DEFAULT NULL COMMENT ‘Fecha de Entrega’,
CONFIRMACION
enum(‘Si’,’No’,’N/A’) DEFAULT NULL COMMENT ‘Confirmacion de Entrega’,
TIEMPO-CICLO
enum(‘1 dia’,’2 dias’,’3 dias’,’4 dias’,’5 dias’,’6 dias’,’7 dias’,’8 dias’,’9 dias’,’10 dias’,’11 dias’,’12 dias’,’13 dias’,’14 dias’,’15 dias’) DEFAULT NULL COMMENT ‘Tiempo de Ciclo’,
DICTAMEN
enum(‘1 dia’,’2 dias’,’3 dias’,’4 dias’,’5 dias’,’6 dias’,’7 dias’,’8 dias’,’9 dias’,’10 dias’,’11 dias’,’12 dias’,’13 dias’,’14 dias’,’15 dias’) DEFAULT NULL COMMENT ‘Dictamen ESE’,
LINK-ESE
text COMMENT ‘Link ESE’,
LINK-AD
text COMMENT ‘Link Antidoping’,
PRIMARY KEY (ID
)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;And this is the PHP code I use to customize the form:
function custom_pruebaese_form ($elements_options, $shortcode_name, $table ){
if ( ‘Prueba ESE Formulario’ === get_post()->post_title && ‘cdbt-entry’ === $shortcode_name && ‘pruebaese’ === $table ) {//Generar ARRAY con query
global $cdbt;
$values = [];
$valuesMonths = [];
$maxValue = [];
$subClientes = [];//Asignamos valores para la lista de CLIENTES
$result = $cdbt->get_data( ‘clientes’, [‘idClientes’,’Cliente’,’CodigoCliente’], [], [‘idClientes’=>’ASC’], ‘ARRAY_A’ );
foreach ( $result as $_i => $_v ) {
$values[] = $_v[‘Cliente’] .’:’. $_v[‘Cliente’];
}//Asignamos valores para la lista de MESES
$result = $cdbt->get_data( ‘meses’, [‘idMes’,’Mes’], [], [‘idMes’=>’ASC’], ‘ARRAY_A’ );
foreach ( $result as $_i => $_v ) {
$valuesMonths[] = $_v[‘Mes’] .’:’. $_v[‘idMes’];
}//Asignamos valores para la lista de SUB-CLIENTES
$result = $cdbt->get_data( ‘subclientes’, [‘idClientes’,’SubCliente’,’CodigoSubCliente’], [], [‘SubCliente’=>’ASC’], ‘ARRAY_A’ );
foreach ( $result as $_i => $_v ) {
$subClientes[] = $_v[‘SubCliente’] .’:’. $_v[‘SubCliente’];
}//Asignamos valores para el COIGO-RODI
$result = $cdbt->get_data(‘pruebaese’, [‘ID’], [], [‘ID’ => ‘ASC’], ‘ARRAY_A’);
foreach ( $result as $_i => $_v ) {
$maxValue[] = $_v[‘ID’];
}echo max($maxValue);
foreach ( $elements_options as $_i => $_option ) {
//Editar campo MES
if ( ‘MES’ === $_option[‘elementName’] ) {
$elements_options[$_i][‘elementLabel’] = __(‘Mes’);
$elements_options[$_i][‘elementType’] = ‘select’;
$elements_options[$_i][‘selectableList’] = implode( ‘,’, $valuesMonths );
$_new_elements_options[0] = $elements_options[$_i];
}//Editar campo CLIENTES
if ( ‘CLIENTE’ === $_option[‘elementName’] ) {
$elements_options[$_i][‘elementLabel’] = __(‘Cliente’);
$elements_options[$_i][‘elementType’] = ‘select’;
$elements_options[$_i][‘selectableList’] = implode( ‘,’, $values);
echo $_option[‘placeholder’];
$_new_elements_options[0] = $elements_options[$_i];
}//Editar campo SUB-CLIENTE
if ( ‘SUB-CLIENTE’ === $_option[‘elementName’] ) {
$elements_options[$_i][‘elementLabel’] = __(‘Seleccion un Sub-Cliente’);
$elements_options[$_i][‘elementType’] = ‘select’;
$elements_options[$_i][‘selectableList’] = implode( ‘,’, $subClientes);
$_new_elements_options[0] = $elements_options[$_i];
}}
}
return $elements_options;
}add_filter( ‘cdbt_shortcode_custom_forms’, ‘custom_pruebaese_form’, 10, 3 );
Customize the form did not cost much, but now I want to make a function that makes a query depending on the value selected in the “CLIENTE” field, ie:
Having value is selected from the drop-down list generated before this value is recorded in the database … ie:
When the user selects a value from the list, this value can be obtained in PHP to generate another field value…
In other words, I want to have a function getCurrentValue() or getSelectedITem(), some of these, for the field “CLIENTE”
I may have the selected value from the list and PHP can manipulate not know if I explain very well, so I leave this in several ways, beforehand thanks for the help
- The topic ‘Get the selected value of a field in a customized form’ is closed to new replies.