name = $name; $this->values = $values; $this->label = $label; $this->parameter = $param; } /** * Apply the parameters from the given request on this widget * * @param Request $request The request to use for populating the form */ public function applyRequest(Request $request) { $this->request = $request; } /** * Return the chosen interval value or null * * @param Request $request The request to fetch the value from * * @return string|null */ public function getInterval(Request $request = null) { if ($request === null && $this->request) { $request = $this->request; } if ($request) { return $request->getParam('interval'); } } /** * Renders this widget and returns the HTML as a string * * @return string */ public function render() { $form = new Form(); $form->setAttrib('class', Form::DEFAULT_CLASSES . ' inline'); $form->setMethod('GET'); $form->setUidDisabled(); $form->setTokenDisabled(); $form->setName($this->name); $form->addElement( 'select', $this->parameter, array( 'label' => $this->label, 'multiOptions' => $this->values, 'autosubmit' => true ) ); if ($this->request) { $form->populate($this->request->getParams()); } return $form; } }