Esempio n. 1
0
 /**
  * @return string
  * returns the input markup for a specific table column
  */
 public function getInputMarkup($config = array())
 {
     //if($this->name == 'exam_id'){ pr($this); }
     // following is used in auto insertForm:
     if (isset($config['name'])) {
         $this->name = $config['name'];
     }
     // the rest is core functionality
     $required = $this->required ? "required" : "";
     $maxLength = $this->maxLength ? "maxlength = '" . $this->maxLength . "'" : "";
     $id_name = "id='" . $this->name . "' name='" . $this->name . "'";
     $classes = "class='form-control'";
     $dataType = "data-type='input'";
     $depFieldsAttribs = $this->getDependantFieldsAttribs($this);
     if ($depFieldsAttribs) {
         $classes = "class='form-control liveFKeyParent'";
     }
     // decide value
     if ($form = isFormSubmitted()) {
         $this->val = $form[$this->name];
     } else {
         if (!$this->val && get_called_class() != 'FilterField') {
             $this->val = $this->defValue ? $this->defValue : "";
         }
     }
     $value = "value='" . $this->val . "'";
     $inputFinalPart = $classes . " " . $id_name . " {$dataType} {$depFieldsAttribs} {$value}  " . $maxLength . " " . $required . ">";
     $output = "<input " . $inputFinalPart;
     // fkey info is treated specially:
     if (!empty($this->fkeyInfo->fClass)) {
         $this->type = 'fkey';
     }
     if (preg_match('/month$/', $this->name)) {
         global $html;
         $output = "<select {$id_name} {$classes} data-type='select'>";
         $output .= $html->monthsOptions($this->val);
         $output .= "</select>";
     } elseif ($this->type == 'int') {
         $output = "<input type='number' " . $inputFinalPart;
     } elseif ($this->type == 'date') {
         $output = "<input type='date' " . $inputFinalPart;
     } elseif ($this->type == 'text') {
         $value = $this->val ? $value : "";
         $output = "<textarea {$id_name} {$classes} data-type='textarea' {$required}>{$this->val}</textarea>";
     } elseif ($this->type == 'fkey') {
         $output = $this->getFkeyInputMarkup($config);
     } elseif ($this->type == 'enum') {
         $output = "<select {$id_name} {$classes} data-type='select'>";
         global $html;
         $output .= $html->getHtmlOptionsForArray($this->enumValues, $this->val, $config);
         $output .= "</select>";
     } elseif (preg_match("/phone/", $this->name)) {
         $output = "<input type='tel' " . $inputFinalPart;
     } elseif (preg_match("/email/", $this->name)) {
         $output = "<input type='email' " . $inputFinalPart;
     } elseif (preg_match("/password/", $this->name)) {
         $output = "<input type='password' " . $inputFinalPart;
     }
     return $output;
 }
Esempio n. 2
0
 * Created by PhpStorm.
 * User: EngrNaveed
 * Date: 29-Dec-14
 * Time: 12:02 PM
 *
 * this page delivers different content for ajax request
 */
require_once __DIR__ . "/" . "../initialize.php";
// $classname may be provided by ajax
if (isset($_POST['classname'])) {
    $classname = $_POST['classname'];
}
// get form markup
$formMarkup = $classname::getFormMarkup();
$formHeading = icon('plus') . " Add a New " . $classname::classTitle();
$in = isFormSubmitted() ? "in" : "";
// ************** show 'add record' link
if (!isAjax()) {
    ?>
<div class="panel-group hidden-print" id="accordion<?php 
    echo $classname;
    ?>
"><?php 
}
?>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h4 class="panel-title">
                <?php 
if (!isAjax()) {
    ?>