Skip to content

Instantly share code, notes, and snippets.

@betobaz
Created November 21, 2012 23:44
Show Gist options
  • Save betobaz/4128589 to your computer and use it in GitHub Desktop.
Save betobaz/4128589 to your computer and use it in GitHub Desktop.
Modificación del vista de edición para asignar valores antes de desplegar
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.edit.php');
class CustomViewEdit extends ViewEdit {
var $ev;
var $type ='edit';
var $useForSubpanel = false; //boolean variable to determine whether view can be used for subpanel creates
var $useModuleQuickCreateTemplate = false; //boolean variable to determine whether or not SubpanelQuickCreate has a separate display function
var $showTitle = true;
function CustomViewEdit(){
parent::ViewEdit();
$this->useForSubpanel = TRUE;
}
function display(){
echo 'test this code is displaying in quick create'; //dummy content -- code to be removed
$this->ev->process();
if($this->ev->isDuplicate) {
foreach($this->ev->fieldDefs as $name=>$defs) {
if(!empty($defs['auto_increment'])) {
$this->ev->fieldDefs[$name]['value'] = '';
}
}
}
echo $this->ev->display($this->showTitle);
}
}
?>
require_once('include/MVC/View/views/view.detail.php');
class ProductsViewEdit extends ViewEdit {
function ProductsViewEdit(){
parent::ViewEdit();
$this->useForSubpanel = true;
}
function display(){
//echo "hola mundo";
$this->ev->process();
if($this->ev->isDuplicate) {
foreach($this->ev->fieldDefs as $name=>$defs) {
if(!empty($defs['auto_increment'])) {
$this->ev->fieldDefs[$name]['value'] = '';
}
}
}
echo print_r($_POST, true);
if(
(isset($_POST['relate_to']) && $_POST['relate_to'] === 'products_products_1' && isset($_POST['relate_id'])) ||
(isset($_POST['parent_type']) && $_POST['parent_type'] === 'Products' && isset($_POST['parent_id']))
){
$productId = isset($_POST['relate_id']) ? $_POST['relate_id'] : $_POST['parent_id'];
$product = new Product();
$product->retrieve($productId);
$this->ev->fieldDefs['familia_c']['value'] = $product->familia_c;
$this->ev->fieldDefs['account_name']['value'] = $product->account_name;
$this->ev->fieldDefs['account_id']['value'] = $product->account_id;
}
echo $this->ev->display($this->showTitle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment