/** @return \KT_Form */ protected function initForm() { $form = new KT_Form(); $form->setAttrId($this->getFormId()); $form->setButtonValue(__("Uložit nastavení", "KT_CORE_DOMAIN")); $form->setButtonClass("kt-form-submit button button-primary"); $form->addFieldSetByObject(KT_User_Profile_Config::getUserProfileFieldset($this->getCurrentUser()->getWpUser())); return $this->form = $form; }
/** * Základní inicializace formuláře * * @author Martin Hlaváč * @link http://www.ktstudio.cz * * @return \KT_Form */ protected function initForm() { $form = new KT_Form(); $form->setAttrId($this->getFormId()); $form->setButtonClass("submitButton"); $form->setButtonValue(__("Odeslat dotaz", "KT_CORE_DOMAIN")); $form->addFieldSetByObject($this->getFieldset()); return $this->form = $form; }
/** * Výchozí callback MetaBoxu, který zpracuje zpracování dat a zobrazení formuláře, či vyvolá dále vlastní callback * Pozn.: není třeba volat "ručně", jedná se o automatickou systémovou funkci * * @author Martin Hlaváč * @link http://www.ktstudio.cz * * @param WP_Post|null $post * @param array $args * @throws KT_Not_Implemented_Exception */ public function metaboxCallback($post, $args) { $dataType = $this->getDataType(); $currentValue = $dataType->getCurrentValue(); $fieldset = $args["args"][0]; $form = null; if (KT::issetAndNotEmpty($fieldset) && $fieldset instanceof KT_Form_Fieldset) { $fieldset->setTitle(""); $form = new KT_Form(); $form->addFieldsetByObject($fieldset); if ($form->isFormSend()) { $form->validate(); } } switch ($currentValue) { case KT_MetaBox_Data_Type_Enum::POST_META: $form->loadDataFromPostMeta($post->ID); break; case KT_MetaBox_Data_Type_Enum::COMMENT_META: $form->loadDataFromCommentMeta($post->comment_ID); break; case KT_MetaBox_Data_Type_Enum::OPTIONS: $form->loadDataFromOptions(); break; case KT_MetaBox_Data_Type_Enum::CRUD: $crudInstance = $this->getCrudInstance(); if (KT::issetAndNotEmpty($crudInstance)) { foreach ($form->getFieldsets() as $fieldset) { $postPrefix = $fieldset->getPostPrefix(); if (KT::issetAndNotEmpty($postPrefix)) { $fieldset->setFieldsData($crudInstance->getData()); } else { throw new KT_Not_Implemented_Exception(__("Zatím jsou podporované pouze formuláře se zadaným PostPrefixem", "KT_CORE_DOMAIN")); } } } break; case KT_MetaBox_Data_Type_Enum::CUSTOM: $customCallback = $this->getCustomCallback(); call_user_func_array("{$customCallback}", array($post, $form ?: $args)); return; default: throw new KT_Not_Implemented_Exception(sprintf(__("Datový typ MetaBoxu: %s", "KT_CORE_DOMAIN"), $currentValue)); } echo $form->getInputsToTable(); }
private function initForm(KT_Form $form) { $fieldset = $this->fieldset = KT_User_Profile_Config::getUserProfileFieldset($this->getCurrentUser()); $form->addFieldSetByObject($fieldset); return $this->form = $form; }
/** * Základní inicializace formuláře * * @author Martin Hlaváč * @link http://www.ktstudio.cz * * @return \KT_Form */ protected function initForm() { $form = new KT_Form(); $form->setAttrId(self::FORM_ID); //$form->setButtonClass(""); $form->setButtonValue(__("Odeslat dotaz", KT_DOMAIN)); $form->addFieldSetByObject($this->getFieldset()); return $this->form = $form; }