public static function validateCreate($descripcion) { $flag = false; $patternC = "^[a-zA-Z0-9]{3,20}\$"; if (ereg($patternC, $descripcion) == false) { session::getInstance()->setError('nop'); $flag = true; session::getInstance()->setFlash(cargoTableClass::getNameField(cargoTableClass::DESCRIPCION, true), true); } if ($flag == true) { request::getInstance()->setMethod('GET'); routing::getInstance()->forward('personal', 'insertCargo'); } }
public function execute() { try { if (request::getInstance()->isMethod('POST')) { $id = request::getInstance()->getPost(cargoTableClass::getNameField(cargoTableClass::ID, true)); $descripcion = request::getInstance()->getPost(cargoTableClass::getNameField(cargoTableClass::DESCRIPCION, true)); $ids = array(cargoTableClass::ID => $id); $data = array(cargoTableClass::DESCRIPCION => $descripcion); cargoTableClass::update($ids, $data); } routing::getInstance()->redirect('personal', 'indexCargo'); } catch (PDOException $exc) { session::getInstance()->setFlash('exc', $exc); routing::getInstance()->forward('shfSecurity', 'exception'); } }
} ?> <div class="container"> <div class="row"> <div class="col-xs-6-offset-3"> <table class="table table-responsive "> <tr> <th> <?php echo i18n::__('cargo', NULL, 'cargo'); ?> :</th> <th> <input required pattern="[a-zA-Z0-9]{3,20}$" placeholder="cargo" name="<?php echo cargoTableClass::getNameField(cargoTableClass::DESCRIPCION, true); ?> "></th> <tr> <th colspan="2"> <div class="titulo"> <input type="submit" value="<?php echo i18n::__(isset($objCargo) == TRUE ? 'edit' : 'register', $culture = NULL); ?> "> </div> </th> </tr> </table> </div>