Ejemplo n.º 1
0
 /**
  * Load all Fields for second tab in popup window when creating /editing documenttemplate
  * @param sfWebRequest $request
  * @return <type>
  */
 public function executeLoadAllFields(sfWebRequest $request) {
     $fieldObj = new FieldClass();
     $result = FieldTable::instance()->getAllFields();
     $json_result = $fieldObj->buildField($result, $this->getContext());
     $this->renderText('({"result":'.json_encode($json_result).'})');
     return sfView::NONE;
 }
Ejemplo n.º 2
0
    /**
     * update a field
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeUpdateField(sfWebRequest $request) {
        $fieldType = FieldTable::instance()->getFieldById($request->getParameter('id'));
        $data = $request->getPostParameters();
        $fieldClass = new FieldClass();
        $data = $fieldClass->prepareSaveData($data); // prepare the data to save, set color and writeprotected flag
        FieldTable::instance()->updateFieldById($request->getParameter('id'), $data);
        switch ($fieldType[0]->getType()) {
            case 'TEXTFIELD':
                FieldTextfieldTable::instance()->updateFieldTextfieldById($request->getParameter('id'), $data);
                break;
            case 'CHECKBOX':
                break;
            case 'NUMBER':
                FieldNumberTable::instance()->updateFieldNumberById($request->getParameter('id'), $data);
                break;
            case 'DATE':
                FieldDateTable::instance()->updateFieldDateById($request->getParameter('id'), $data);
                break;
            case 'TEXTAREA':
                $data['fieldTextarea_content'] = $data['fieldTextarea_contenttype'] == 'plain' ? $data['fieldTextarea_textarea']: $data['fieldTextarea_htmlarea'];
                FieldTextareaTable::instance()->updateFieldTextareaById($request->getParameter('id'), $data);
                break;
            case 'RADIOGROUP':
                $fieldClass->saveRadiogroup($request->getParameter('id'), $data);
                break;
            case 'CHECKBOXGROUP':
                $fieldClass->saveCheckboxgroup($request->getParameter('id'), $data);
                break;
            case 'COMBOBOX':
                $fieldClass->saveCombobox($request->getParameter('id'), $data);
                break;
            case 'FILE':
                FieldFileTable::instance()->updateFieldFileById($request->getParameter('id'), $data);
                break;
        }
		$this->renderText('{success:true}');
        return sfView::NONE;
    }