Beispiel #1
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         $formatName = CRM_Core_BAO_PdfFormat::getFieldValue('CRM_Core_BAO_PdfFormat', $this->_id, 'name');
         $this->assign('formatName', $formatName);
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat');
     $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
     $this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
     $this->add('checkbox', 'is_default', ts('Is this PDF Page Format the default?'));
     $this->add('select', 'paper_size', ts('Paper Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value );"));
     $this->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
     $this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions();"));
     $this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
     $this->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
     $this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
     $this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
     $this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_BAO_PdfFormat', $this->_id));
     $this->addRule('margin_left', ts('Margin must be numeric'), 'numeric');
     $this->addRule('margin_right', ts('Margin must be numeric'), 'numeric');
     $this->addRule('margin_top', ts('Margin must be numeric'), 'numeric');
     $this->addRule('margin_bottom', ts('Margin must be numeric'), 'numeric');
     $this->addRule('weight', ts('Weight must be integer'), 'integer');
 }