Forums

Run PHP code in custom button in toolbar

inocampo 02 Dec, 2014
Hi

How can run PHP code with Custom Button in CCV5 Toolbar

Thank yoy

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 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.
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?
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.