Не могу вывести форму редактирования, не отображается текст: http://prntscr.com/l9bo0h не обращайте внимание на названия, функционал взят из формы добавления.
Рекомендованные сообщения
Создайте аккаунт или войдите в него для комментирования
При использовании данного сайта, вы согласаетесь с Условия использования и Чтобы сделать этот веб-сайт лучше, мы разместили cookies на вашем устройстве. Вы можете изменить свои настройки cookies, в противном случае мы будем считать, что вы согласны с этим..
Здравствуйте. Пишу просто модуль, для добавления/редактирования/удаления записей из БД. Получилось следующее:
<?php namespace IPS\sharedstats\modules\admin\stats; /* To prevent PHP errors (extending class does not exist) revealing path */ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) ) { header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' ); exit; } /** * announce */ class _announce extends \IPS\Dispatcher\Controller { /** * Execute * * @return void */ public function execute() { \IPS\Dispatcher::i()->checkAcpPermission( 'Can change announce?' ); \IPS\sharedstats\DB::get(); parent::execute(); } /** * Manage * * @return void */ protected function manage() { /* Create the table */ $table = new \IPS\sharedstats\DbIntegration\Db( 'stats_announces', \IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce' ), NULL, NULL, NULL, 'stats' ); $table->langPrefix = 'sharedstats_stats_announce_'; /* Root buttons */ $table->rootButtons = array( 'add' => array( 'icon' => 'cross', 'title' => 'sharedstats_stats_announce_announce_add', 'link' => \IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce&do=add' ), ) ); /* Row buttons */ $table->rowButtons = function ( $row ) { $return['edit'] = array( 'icon' => 'pencil', 'title' => 'edit', 'link' => \IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce&do=edit&id=' . $row['id'] ), ); $return['del'] = array( 'icon' => 'times-circle', 'title' => 'sharedstats_stats_announce_announce_delete', 'link' => \IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce&do=delete&id=' . $row['id'] ), ); return $return; }; /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__sharedstats_stats_announce'); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table ); } protected function add() { $form = new \IPS\Helpers\Form(); $form->addHeader( 'sharedstats_stats_announce_announce_add' ); $form->add( new \IPS\Helpers\Form\TextArea( 'sharedstats_stats_announce_announce_add', null, true)); if ( $values = $form->values() ) { $ann = new \IPS\sharedstats\Records\Announce; $ann->text = mb_strtolower($values['sharedstats_stats_announce_announce_add']); $ann->save(); \IPS\Output::i()->redirect(\IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce', 'admin' ), 'sharedstats_stats_announce_announce_added'); } \IPS\Output::i()->output = $form; } protected function edit() { $id = \IPS\Request::i()->id; $announce = \IPS\sharedstats\Records\Announce::load($id); $form = new \IPS\Helpers\Form(); $form->addHeader( 'sharedstats_stats_announce_announce_add' ); $form->add( new \IPS\Helpers\Form\TextArea( 'sharedstats_stats_announce_announce_add', null, true)); if ( $values = $form->values() ) { $announce->text = mb_strtolower($values['sharedstats_stats_announce_announce_add']); $announce->save(); \IPS\Output::i()->redirect(\IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce', 'admin' ), 'sharedstats_stats_announce_announce_added'); } \IPS\Output::i()->output = $form; } protected function delete() { $id = \IPS\Request::i()->id; $announce = \IPS\sharedstats\Records\Announce::load($id); $announce->delete(); \IPS\Output::i()->redirect(\IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=announce', 'admin' ), 'sharedstats_stats_announce_announce_deleted'); } }Не могу вывести форму редактирования, не отображается текст: http://prntscr.com/l9bo0h не обращайте внимание на названия, функционал взят из формы добавления.