/** * Constructs the field * * @param string $column Field column name * @param string $label Field label * @throws \InvalidArgumentException */ public function __construct($label, $targetTable, $fixedField, $fixedFieldValue, \TotalFlex\DBSource $dbSource) { $this->_targetTable = $targetTable; $this->_fixedField = $fixedField; $this->_fixedFieldValue = $fixedFieldValue; $this->_source = $dbSource; $this->_instanceId = ++self::$instanceCount; $this->_elementId = str_replace("\\", "_", get_class($this)) . $this->_instanceId; $this->_sourceLinkField = $dbSource->getFieldKey(); $this->_sourceLabel = $dbSource->getFieldLabel(); if (empty(self::$defaultTemplate)) { self::$defaultTemplate = Select::getDefaultTemplate(); } // parent::__construct ( $column , $label ); if (empty($this->_encloseStart)) { $this->_encloseStart = static::$defaultEncloseStart; } if (empty($this->_encloseEnd)) { $this->_encloseEnd = static::$defaultEncloseEnd; } if (empty($this->_template)) { $this->_template = static::$defaultTemplate; } if (empty($this->_labelTemplate)) { $this->_labelTemplate = static::$defaultLabelTemplate; } $this->setLabel($label)->setType('text')->setPrimaryKey(false)->setRules([]); if (\TotalFlex\TotalFlex::getDefaultDB() === null) { throw new DefaultDBNotSet("You have to set default db with TotalFlex::setDefaultDB() or give it as an argument in constructor method"); } $this->db = \TotalFlex\TotalFlex::getDefaultDB(); $this->_options = $dbSource->getFieldAsKeyLabelAsValue(); }
<head> <meta charset="UTF-8"> <title>Document</title> <!-- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" /> --> <link href="http://imidiatv.dev/assets/bootstrap-3.3.2/css/bootstrap.min.css" rel="stylesheet" /> <style> *,html,body{font-size: 1em;} </style> </head> <body> <?php // Registering table `business_entity` with its fields $TotalFlex->registerView('business_entity')->setContexts(TotalFlex::CtxUpdate | TotalFlex::CtxCreate)->addField(Field\Text::getInstance("id_user", "ID"))->setPrimaryKey()->addField("name", "Nome")->addField(Field\SelectMultiOptions::getInstance("Perfis de acesso do usuário", "role_user", "id_user", "4", \TotalFlex\DBSource::getInstance("description", "id_role", "SELECT id_role , description FROM role")))->addButton(Button::getInstance("Salvar", array("type" => "submit")))->setTable("user")->where("id_user = 4"); // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxCreate , function ( ) { }) ; // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxUpdate ) ; // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxCreate ) ; echo \TotalFlex\Feedback::dumpMessages(); // prs($pdo->query("SELECT * FROM news_label")->fetchAll()); // pr($consulta->fetchAll()); // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxUpdate ) ; // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxRead ) ; // $TotalFlex->processPost ( "business_entity" , TotalFlex::CtxUpdate|TotalFlex::CtxRead|TotalFlex::CtxCreate ) ; /************************************************************ * TotalFlex Use Case * --------------------------------------------------------- * This is the real code to generate some form with TotalFlex * AND handle the return. *************************************************************/