Ejemplo n.º 1
0
 public function addFieldSelect($name, Am_Table $table, $title, array $options)
 {
     $fs = $this->form->addFieldset()->setLabel($title . ' Columns: ' . $table->getName(true));
     $sampleRows = $table->getAdapter()->select("SELECT * FROM ?#\n            LIMIT ?d,3", $table->getName(true), max($table->countBy() - 3, 0));
     $sample = "<div style='color: lightgray'>";
     foreach ($sampleRows as $r) {
         $sample .= nl2br(Am_Controller::escape(substr(print_r($r, true), 0, 1024))) . "\n";
     }
     $sample .= "</div>";
     $fs->addStatic()->setLabel('Sample Rows')->setContent($sample);
     $fields = $table->getFields(true);
     $fields = array_merge(array(''), $fields);
     foreach ($options as $k => $v) {
         $el = $fs->addSelect('field[' . $name . '][' . $k . ']')->setLabel($v)->loadOptions(array_combine($fields, $fields));
         if (!in_array($k, array('Am_Protect_SessionTable::FIELD_UID', 'Am_Protect_SessionTable::FIELD_IP', 'Am_Protect_SessionTable::FIELD_UA', 'Am_Protect_SessionTable::FIELD_CREATED', 'Am_Protect_SessionTable::FIELD_CHANGED'))) {
             $el->addRule('required');
         }
     }
 }