/** * Renders the Sell Price Formula Dropdown * @param Redbean $model * @param Object $form * @param string $inputNameIdPrefix * @param string $attribute * @return string */ protected function renderNameDropDown($model, $form, $inputNameIdPrefix, $attribute) { $id = $this->getEditableInputId($inputNameIdPrefix, $attribute); $discountOrMarkupPercentageTextFieldId = $this->getEditableInputId($inputNameIdPrefix, 'discountOrMarkupPercentage'); $sellPriceValueId = $this->getEditableInputId('sellPrice', 'value'); $htmlOptions = array('name' => $this->getEditableInputName($this->attribute, 'type'), 'id' => $id, 'onchange' => 'showHideDiscountOrMarkupPercentageTextField($(this).val(), \'' . $discountOrMarkupPercentageTextFieldId . '\'); enableDisableSellPriceElementBySellPriceFormula($(this).val(), \'' . $sellPriceValueId . '\', "sellPrice"); calculateSellPriceBySellPriceFormula()'); $dropDownField = $form->dropDownList($model, $attribute, SellPriceFormula::getTypeDropDownArray(), $htmlOptions); $error = $form->error($model, $attribute, array('inputID' => $id)); return $dropDownField . $error; }
/** * @return array */ protected function getDropDownArray() { return SellPriceFormula::getTypeDropDownArray(); }
/** * Get sell price formula type displayed value * @param RedBeanModel $data * @param string $attribute * @return string */ public static function getSellPriceFormulaType($data, $attribute) { $dataArray = SellPriceFormula::getTypeDropDownArray(); return $dataArray[$data->getModel($attribute)->sellPriceFormula->type]; }
public function __construct($modelClassName, $attributeName) { parent::__construct($modelClassName, $attributeName); $this->dropDownValues = SellPriceFormula::getTypeDropDownArray(); }