public function init() { parent::init(); $this->removeElement("id"); $e = new Daq_Form_Element("coupon"); $e->setLabel(__("Coupon", WPJB_DOMAIN)); $this->addElement($e, "coupon"); $payment = new Wpjb_Payment_Factory(); if (count($payment->getEngines()) > 1) { $v = array(); $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_SELECT); $e->setRequired(true); $e->setLabel(__("Payment Method", WPJB_DOMAIN)); foreach ($payment->getEngines() as $key => $engine) { /* @var $engine Wpjb_Payment_Interface */ $engine = new $engine(); $pTitle = $engine->getTitle(); $e->addOption($key, $key, $pTitle); $v[] = $key; } $e->addValidator(new Daq_Validate_InArray($v)); $this->addElement($e, "coupon"); } else { $engine = current($payment->getEngines()); $engine = new $engine(); $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_HIDDEN); $e->setValue($engine->getEngine()); $e->addValidator(new Daq_Validate_InArray(array($engine->getEngine()))); $e->setRequired(true); $this->addGroup("hidden"); $this->addElement($e, "hidden"); } $e = new Daq_Form_Element("listing", Daq_Form_Element::TYPE_RADIO); $e->setRequired(true); $e->setLabel(__("Listing Type", WPJB_DOMAIN)); $e->addValidator(new Daq_Validate_Db_RecordExists("Wpjb_Model_Listing", "id")); $default = __("<b>{title}</b> {price} ~ days visible: {visible}", WPJB_DOMAIN); $tpl = Wpjb_Project::getInstance()->conf("front_listing_tpl", $default); foreach ($this->_getListingArr() as $listing) { $visible = $listing->visible; if ($visible == 0) { $visible = __("<i>unlimited</i>", WPJB_DOMAIN); } $find = array("{price}", "{title}", "{visible}"); $repl = array($listing->getTextPrice(), $listing->title, $visible); $e->addOption($listing->id, $listing->id, str_replace($find, $repl, $tpl)); } $e->setRenderer("wpjb_form_helper_listing"); $this->addElement($e, "coupon"); apply_filters("wpjb_form_init_addjob", $this); $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_add_job", true)); }
public function init() { parent::init(); $this->addGroup("other", "Other"); $e = new Daq_Form_Element("is_filled", Daq_Form_Element::TYPE_CHECKBOX); $e->setLabel(__("Is Filled", WPJB_DOMAIN)); $e->setValue($this->getObject()->is_filled); $e->addOption(1, 1, __("Yes, this position is taken", WPJB_DOMAIN)); $e->addFilter(new Daq_Filter_Int()); $this->addElement($e, "other"); apply_filters("wpja_form_init_editjob", $this); $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_add_job", true)); }
public function init() { parent::init(); $this->addGroup("other", "Other"); $e = new Daq_Form_Element("job_slug"); $e->setRequired(true); $e->setLabel(__("Job Slug", WPJB_DOMAIN)); $e->setHint(__("The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.", WPJB_DOMAIN)); $e->setValue($this->_object->job_slug); $e->addValidator(new Daq_Validate_StringLength(1, 120)); $e->addValidator(new Daq_Validate_Slug()); $e->addValidator(new Daq_Validate_Db_NoRecordExists("Wpjb_Model_Job", "job_slug", $this->_exclude())); $this->addElement($e, "other"); $e = new Daq_Form_Element("is_active", Daq_Form_Element::TYPE_CHECKBOX); $e->setLabel(__("Is Active", WPJB_DOMAIN)); $e->setValue($this->_object->is_active); $e->addFilter(new Daq_Filter_Int()); $e->addOption(1, 1, __("Yes", WPJB_DOMAIN)); $this->addElement($e, "other"); if ($this->getObject()->getId() && $this->isAdminMode()) { $e = new Daq_Form_Element("is_featured", Daq_Form_Element::TYPE_CHECKBOX); $e->setLabel(__("Is Featured", WPJB_DOMAIN)); $e->setValue($this->getObject()->is_featured); $e->addOption(1, 1, __("Yes", WPJB_DOMAIN)); $e->addFilter(new Daq_Filter_Float()); $this->addElement($e, "other"); $e = new Daq_Form_Element("job_visible"); $e->setLabel(__("Visible", WPJB_DOMAIN)); $e->setValue($this->getObject()->job_visible); $e->setHint(__("Number of days job will be visible (Overwrites listing type settings)", WPJB_DOMAIN)); $e->addFilter(new Daq_Filter_Int()); $e->addValidator(new Daq_Validate_Int(0)); $this->addElement($e, "other"); } if (!$this->getObject()->getId()) { $e = new Daq_Form_Element("listing", Daq_Form_Element::TYPE_SELECT); $e->setLabel(__("Listing Type", WPJB_DOMAIN)); $e->addValidator(new Daq_Validate_Db_RecordExists("Wpjb_Model_Listing", "id")); foreach ($this->_getListingArr() as $listing) { $e->addOption($listing->id, $listing->id, $listing->title); } $this->addElement($e, "other"); } if (!$this->isAdminMode()) { $this->removeElement("is_active"); $this->removeElement("job_slug"); } $e = new Daq_Form_Element("is_filled", Daq_Form_Element::TYPE_CHECKBOX); $e->setLabel(__("Is Filled", WPJB_DOMAIN)); $e->setValue($this->getObject()->is_filled); $e->addOption(1, 1, __("Yes, this position is taken", WPJB_DOMAIN)); $e->addFilter(new Daq_Filter_Int()); $this->addElement($e, "other"); if ($this->getObject()->getId() > 0 && !$this->getObject()->isFree()) { $e = new Daq_Form_Element("payment_paid"); $e->setValue($this->_object->payment_paid); $e->addValidator(new Daq_Validate_Float()); $this->addElement($e, "unknown"); } apply_filters("wpja_form_init_addjob", $this); $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_add_job", true)); }