Ejemplo n.º 1
0
 public function render()
 {
     $name = $this->getName();
     $hidden = new HiddenField($name, $this->getValue());
     $id = $this->getId();
     $hidden->addAttribute("id", $id);
     $ret = $hidden->render();
     if ($this->storedFieldSet === false) {
         $this->addSearchField($this->storedField);
         $this->storedFieldSet = true;
     }
     $object = array("model" => $this->model->package, "format" => "json", "fields" => $this->searchFields, "limit" => 20, "conditions" => "", "and_conditions" => $this->andConditions);
     $jsonSearchFields = array_reverse($this->searchFields);
     $object = base64_encode(serialize($object));
     $path = Application::$prefix . "/lib/models/urlaccess.php?object={$object}";
     $fields = urlencode(json_encode($jsonSearchFields));
     $text = new TextField();
     $text->addAttribute("onkeyup", "fapiUpdateSearchField('{$id}','{$path}','{$fields}',this," . ($this->boldFirst ? "true" : "false") . ",'{$this->onChangeAttribute}')");
     $text->addAttribute("autocomplete", "off");
     if ($this->getValue() != "") {
         $data = $this->model[$this->getValue()];
         for ($i = 2; $i < count($jsonSearchFields); $i++) {
             $val .= $data[0][$jsonSearchFields[$i]] . " ";
         }
         $text->setValue($val);
     }
     $text->setId($id . "_search_entry");
     $ret .= $text->render();
     $ret .= "<div class='fapi-popup' id='{$id}_search_area'></div>";
     return $ret;
 }
Ejemplo n.º 2
0
 function __construct()
 {
     parent::__construct('clone-form');
     $this->ajax = true;
     $this->setAction(OW::getRouter()->urlFor('ADMIN_CTRL_Languages', 'ajaxClone'));
     $this->setMethod('post');
     $labelTextField = new TextField('label');
     $labelTextField->setLabel(OW::getLanguage()->text('admin', 'clone_form_lbl_label'))->setDescription(OW::getLanguage()->text('admin', 'clone_form_descr_label'));
     $this->addElement($labelTextField);
     $tagTextField = new TextField('tag');
     $tagTextField->addValidator(new LanguageTagValidator());
     $tagTextField->setLabel(OW::getLanguage()->text('admin', 'clone_form_lbl_tag'))->setDescription(OW::getLanguage()->text('admin', 'clone_form_descr_tag'));
     $this->addElement($tagTextField);
     $hiddenField = new HiddenField('language');
     $hiddenField->addAttribute('class', 'hidden_lang_tag');
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('admin', 'clone_form_lbl_submit'));
     $this->addElement($submit);
     $this->addElement($hiddenField);
     //value to be set by javascript
     if (!OW::getRequest()->isAjax()) {
         OW::getDocument()->addOnloadScript("owForms['{$this->getName()}'].bind('success', function(){location.reload();});");
     }
 }