Run PHP code in custom button in toolbar

How to run PHP code from a custom toolbar button in ChronoForms.

Overview

The issue occurred because the built-in 'toggle' task does not support processing multiple data records, leading to a database error.
Create a custom action in your form's connection, point it to a ChronoForms event, and write PHP code within that event to properly loop through and update the selected records.

Answered
in inocampo 02 Dec, 2014
Hi

How can run PHP code with Custom Button in CCV5 Toolbar

Thank yoy

Run PHP code in custom button in toolbar image 1
in inocampo 02 Dec, 2014
Hi

For update one field i used this code

$this->view->Toolbar->addButton("toolbar-button-remove","/manifestar.html?cont=lists&act=toggle&ccname=list_manifestar&val=1&fld=manifestado&gcb={a.id}", "Manifestar", "/libraries/cegcore/assets/images/toolbar/settings.png", "submit_selectors");


And I have this error

Unknown column 'Array' in 'where clause' SQL=UPDATE `s14pd_chronoengine_chronoforms_datatable_frm_warehouse` AS `a` SET `manifestado` = '1' WHERE `id` = Array;


Thank you
Max_admin Max_admin 02 Dec, 2014
Hi inocampo,

The "toggle" task doesn't support multiple data and so you will need to point to a custom action (which you will need to create in your connection then set its permissions and point it to a Chronoforms event) and use that action to update the submitted IDs.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
in inocampo 03 Dec, 2014
Hi

I can make in (gcontrollers.php) a new action for my custom toolbar?
an action same (_save_list)

I can do it?
in inocampo 03 Dec, 2014
Answer
Solved



<?php
date_default_timezone_set('America/Bogota');
$db = JFactory::getDBO();
$user = JFactory::getUser();
//============================== get current user id 
$usuario =  $user->id;

//============================== insert another table get last insert
$query = "INSERT INTO #__chronoengine_chronoforms_datatable_frm_manifiesto (usuario) VALUES ('$usuario')";
$db->setQuery($query);
$db->query();
$id = $db->insertid();

//============================== get array CCV5
$guias=\GCore\Models\a::getInstance()->find("list", array("fields" => array("id", "id"), "conditions" => array("id" => $form->data("gcb"))));
//pr($guias);

//============================== update table
$hoy=date('Y-m-d H:i:s');
foreach ($guias as $guia) {
$query1 = "UPDATE #__chronoengine_chronoforms_datatable_frm_warehouse SET manifiesto_agencia = '$id', manifestado='1', fecha_manifestado='$hoy' WHERE id = '$guia'"; 
$db->setQuery($query1);
$db->query();
}


// ======================= Redirect form
$ruta=JURI::root();
$app = JFactory::getApplication();
$app->redirect($ruta.'/index.php/nueva-agencia');
?>
This topic is locked and no more replies can be posted.