别名“bootstrap.widgets.input.TbInput”无效。确保它指向现有目录或文件

时间:2015-07-13 17:46:11

标签: php twitter-bootstrap yii yii-extensions

在youtube上观看视频并在此网站上关注了如此多的指南,例如:this等等,当我尝试添加新表单时出现以下错误:

  

别名“bootstrap.widgets.input.TbInput”无效。确保它   指向现有目录或文件。

这是我的main.config:

<?php
Yii::setPathOfAlias('booster', dirname(__FILE__) . './../extensions/booster');
/**
 * This is the main Web application configuration.
 *
 * Any writable CWebApplication properties can be configured here.
 * It is constructed the following way:
 *    main.php = return the main settings
 *                  unless overwritten by the local main settings if available
 *                  unless overwritten by the test settings if available
 *                  unless overwritten by the local test settings if available
 * (mergeArray: latter will overwrite the former, see http://www.yiiframework.com/doc/api/1.1/CMap#mergeArray-detail)
 *
 * @author Yii, adapted by Robbert <Paulussen@Momentum-Technologies.nl>
 * @since release 1.0 (sprint 1)
 */
// Set up path variables to reflect the directory structure
// $WEBHOME/                     -- doePath
// $WEBHOME/public/              -- webrootPath
// $WEBHOME/private/protected/   -- protectedPath
// $WEBHOME/private/runtime/     -- runtimePath

$pathToDoeDirectory  = realpath(dirname(__FILE__) . '/../../..');
$privatePath         = $pathToDoeDirectory . '/private/';
$protectedPath       = $pathToDoeDirectory . '/private/protected/';
$runtimePath         = $pathToDoeDirectory . '/private/runtime/';
$publicPath          = $pathToDoeDirectory . '/public/';
$webrootPath         = $publicPath;

/**
 * Namespace MTE
 */
Yii::setPathOfAlias('MTE', $protectedPath);

// used by the themeUrl of widgetFactory settings, in case the DOE is in a subdirectory
$baseUrl = (isset($_SERVER['DOCUMENT_ROOT'])) ? str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath('.')) : '';

//define('EOL','<br/>');
//echo '$pathToCcsDirectory = ' . $pathToCcsDirectory . PHP_EOL;
//echo '$privatePath = ' . $privatePath . PHP_EOL;
//echo '$protectedPath = ' . $protectedPath . PHP_EOL;
//echo '$runtimePath = ' . $runtimePath . PHP_EOL;
//echo '$publicPath = ' . $publicPath . PHP_EOL;
//echo '$webrootPath = ' . $webrootPath . PHP_EOL;
/** the following defines path aliases using:   Yii::setPathOfAlias('local','path/to/local-folder');
 * usage e.g.  ... Yii::getPathOfAlias('runtimePath') ...
 */
Yii::setPathOfAlias('doePath', $pathToDoeDirectory);
Yii::setPathOfAlias('privatePath', $privatePath);
Yii::setPathOfAlias('publicPath', $publicPath);
Yii::setPathOfAlias('protectedPath', $protectedPath);
Yii::setPathOfAlias('runtimePath', $runtimePath);
Yii::setPathOfAlias('webrootPath', $webrootPath);
$config_database = require(dirname(__FILE__) . '/database.php');

$config_main = array(
    'sourceLanguage' => 'en', // for i18N
    'timeZone'       => 'Europe/Amsterdam',
    'basePath'       => $protectedPath,
    // override the default of Yii
    'runtimePath'    => $runtimePath,
    'name'           => Yii::t('systemwide', 'DOEN - DOssier opvolg- EN actiesysteem'),
    //'theme'=>'bootstrap',
    // preloading 'log' component
    'preload'        => array(
        'log',
        'translate', // for i18N
        'booster',   //bootstrap
    ),
    'behaviors' => array(
        'onBeginRequest' => array(
            'class'  => 'application.components.modulesloader',),
    ), // for i18N
    // autoloading model and component classes, Note that importing a directory does not import any of its subdirectories!
    'import' => array(
        'application.components.*',
        'application.models.*',
        'application.modules.rights.*',
        'application.modules.rights.components.*',
        'application.modules.translate.TranslateModule',
        'booster.helpers.TbHtml',
        'booster.helpers.TbArray',
        'booster.behaviors.TbWidget',
        'booster.widgets.*'
    ),
    'modules' => array(
        'gii'    => array('generatorPaths' => array('booster.gii',),),
        'rights' => array(
            'install'        => false, // Whether to install rights.
            'userNameColumn' => 'login', // Name of the user name column in the database.
            'userClass'      => 'RightsModuleUser', // extended User model
            'cssFile'        => '/MTE/modules/rights/default.css', // custom css for rights module
            'superuserName'  => 'MTeAdmin', // doe_user.login of the user with super user privileges. Default 'Admin'

            /*'generatorPaths' =>array(
                'bootstrap.gii',
             ),*/
        /* more options */
//          'appLayout'          => 'application.views.layouts.main', // Application layout.
//          'authenticatedName'  => 'Authenticated',                // Name of the authenticated user role.
//          'baseUrl'            => '/rights',                      // Base URL for Rights. Change if module is nested.
//          'debug'              => false,                          // Whether to enable debug mode.
//          'displayDescription' => true,                           // Whether to use item description instead of name.
//          'enableBizRule'      => true,                           // Whether to enable authorization item business rules.
//          'enableBizRuleData'  => false,                          // Whether to enable data for business rules.
//          'flashErrorKey'      => 'RightsError',                  // Key to use for setting error flash messages.
//          'flashSuccessKey'    => 'RightsSuccess',                // Key to use for setting success flash messages.
//          'layout'             => 'rights.views.layouts.main',    // Layout to use for displaying Rights.
//          'userIdColumn'       => 'id',                           // Name of the user id column in the database.
        ),
        'translate',
        'components'     => array(
            //use component to store the cookies
            'Cookies' => array(
                'class'      => 'application.components.CookiesHelper'
            ),
            // uncomment the following to enable URLs in path-format
            'urlManager' => array(
                'urlFormat'      => 'path',
                'showScriptName' => false,
                'rules'          => array(
                    '<controller:\w+>/<id:\d+>'              => '<controller>/view',
                    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                    '<controller:\w+>/<action:\w+>'          => '<controller>/<action>',
                ),
            ),
            'errorHandler'                           => array(
                // use 'site/error' action to display errors
                'errorAction'    => 'site/error',
            ),
            'booster' => array(
                'class' => 'ext.booster.components.Booster'
            ),
            'log'            => array(
                'class'  => 'CLogRouter',
                'routes' => array(
                    array(
                        'class'      => 'CFileLogRoute',
                        'levels'     => 'info, warning, error',
                    ),
                ),
            ),
        ),
    ),
    // application components
    'components' => array(
        // this class is used to simplify template actions
        'TemplateHelper' => array(
            'class'      => 'application.components.TemplateHelper',
        ),
        /* i18N - begin */
        'messages'   => array(
            'class'                  => 'CDbMessageSource',
            'onMissingTranslation'   => array('TranslateModule',
                'missingTranslation',
            ),
        ),
        'translate' => array(
            'class'              => 'translate.components.MPTranslate',
            'acceptedLanguages'  => array(
                'en'             => 'English',
                'nl'             => 'Nederlands',
            ),
        ),
        /* i18N - end */
        'authManager'    => array(
            'class'          => 'RDbAuthManager',
            'connectionID'   => 'db',
            'defaultRoles'   => array('authenticated', 'user'),
        ),
        'user' => array(
            'class'          => 'WebUser',
            /* enable cookie-based authentication */
            'allowAutoLogin' => true,
            /* @see http://www.yiiframework.com/doc/guide/1.1/en/topics.auth */
            'loginUrl'       => array('/site/login'),
        ),
        'booster' => array(
            'class' => 'ext.booster.components.Booster'
        ),
    ),
    /** application-level parameters that can be accessed
     *  using Yii::app()->params['paramName']
     */
    'params' => array(
        // this is used in contact page
        'adminEmail'         => 'beheer@momentum-technologies.nl',
        'cookie_duration'    => 3600 * 24 * 30,
        'composer.callbacks' => array(
            // args for Yii command runner
            'yiisoft/yii-install' => array('yiic', 'webapp', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'),
            'post-update' => array('yiic', 'migrate'),
            'post-install' => array('yiic', 'migrate'),
        ),
    ),
);
$mainDbIncluded = CMap::mergeArray($config_database, $config_main);

// include and merge local main config if it exists
if (file_exists(dirname(__FILE__) . '/main-local.php'))
{
    return CMap::mergeArray($mainDbIncluded, include(dirname(__FILE__) . '/main-local.php'));
}
// otherwise just load the main config file
return $mainDbIncluded;

当我添加此代码时:

<?php
            $form = $this->beginWidget('booster.widgets.TbActiveForm',
                array(
                    'id'                     => 'login-form',
                    'enableClientValidation' => true,
                    'clientOptions'          => array(
                    'validateOnSubmit' => true,
                    ),
                )
            );
            ?>

直接来自here,我仍然得到错误,我尝试了不同的解决方案,但我无法弄清楚问题,我该如何解决这个请帮助。我甚至遵循了这个one,但它没有帮助。

1 个答案:

答案 0 :(得分:0)

  

Alias&#34; bootstrap.widgets.input.TbInput&#34;无效

您要使用 bootstrap 别名而不是 booster 。还要确保将下载的zip解压缩到/ protected / extension / booster文件夹(复制粘贴文件夹名称)。如果错误仍然存​​在,请尝试直接调用。

<?php $this->widget('ext.booster.widgets.TbActiveForm'); ?>