/** * Add boolean field * @param string $key * @param string $label */ private function addBooleanField($key, $label) { $Field = new FormularSelectBox($key, $label); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W33); $Field->setOptions(array('' => '', '1' => __('Yes'), '0' => __('No'))); $this->Fieldset->addField($Field); }
/** * Init fieldset for input data */ protected function initFieldsetForInputData() { $this->FieldsetInput = new FormularFieldset(__('Input')); foreach ($this->InfoLines as $InfoMessage) { $this->FieldsetInput->addInfo($InfoMessage); } $FieldModel = new FormularSelectBox('model', __('Model')); $FieldModel->addOption('jack-daniels', 'Jack Daniels (VDOT)'); $FieldModel->addOption('robert-bock', 'Robert Bock (CPP)'); $FieldModel->addOption('herbert-steffny', 'Herbert Steffny'); $FieldModel->addOption('david-cameron', 'David Cameron'); $FieldModel->addAttribute('onchange', '$(\'#prognosis-calculator .only-\'+$(this).val()).closest(\'div\').show();$(\'#prognosis-calculator .hide-on-model-change:not(.only-\'+$(this).val()+\')\').closest(\'div\').hide();'); $FieldModel->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100); $FieldDistances = new FormularInput('distances', __('Distances')); $FieldDistances->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100); $FieldDistances->setSize(FormularInput::$SIZE_FULL_INLINE); $this->FieldsetInput->addField($FieldModel); $this->FieldsetInput->addField($FieldDistances); $this->addFieldsForJackDaniels(); $this->addFieldsForBockAndSteffny(); }
/** * Get input for active * @param bool $active * @return FormularSelectBox */ protected function getActiveInputCode($active) { $FieldActive = new FormularSelectBox('splits[active][]', '', (int) $active); $FieldActive->setOptions(array(__('Resting'), __('Active'))); $FieldActive->setLayout(FormularFieldset::$LAYOUT_FIELD_INLINE); return $FieldActive->getCode(); }
/** * Display fieldset: Equipment */ protected function initEquipmentFieldset() { $isCreateForm = $this->submitMode == StandardFormular::$SUBMIT_MODE_CREATE; $Factory = new Factory(SessionAccountHandler::getId()); $AllEquipment = $Factory->allEquipments(); $RelatedEquipment = $isCreateForm ? array() : $Factory->equipmentForActivity($this->dataObject->id(), true); $Fieldset = new FormularFieldset(__('Equipment')); $Fieldset->addField(new FormularInputHidden('equipment_old', '', implode(',', $RelatedEquipment))); if (isset($_POST['equipment'])) { $RelatedEquipment = self::readEquipmentFromPost(); } foreach ($Factory->allEquipmentTypes() as $EquipmentType) { $options = array(); $values = array(); $attributes = array(); foreach ($AllEquipment as $Equipment) { if ($Equipment->typeid() == $EquipmentType->id() && (!$isCreateForm || $Equipment->isInUse())) { $options[$Equipment->id()] = $Equipment->name(); $attributes[$Equipment->id()] = array('data-start' => $Equipment->startDate(), 'data-end' => $Equipment->endDate()); if (in_array($Equipment->id(), $RelatedEquipment)) { $values[$Equipment->id()] = 'on'; } } } if (empty($options)) { continue; } if ($EquipmentType->allowsMultipleValues()) { $Field = new FormularCheckboxes('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $values); foreach ($options as $key => $label) { $Field->addCheckbox($key, $label, $attributes[$key]); } } else { $selected = !empty($values) ? array_keys($values) : array(0); $Field = new FormularSelectBox('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $selected[0]); $Field->addOption(0, ''); foreach ($options as $key => $label) { $Field->addOption($key, $label, $attributes[$key]); } } $SportClasses = 'only-specific-sports'; foreach ($Factory->sportForEquipmentType($EquipmentType->id(), true) as $id) { $SportClasses .= ' only-sport-' . $id; } $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_IN_W50); $Field->addLayoutClass($SportClasses . ' depends-on-date'); $Field->addAttribute('class', FormularInput::$SIZE_FULL_INLINE); $Fieldset->addField($Field); } $this->addFieldset($Fieldset); }