begin() public static method

This method creates an instance of the calling class. It will apply the configuration to the created instance. A matching Widget::end call should be called later. As some widgets may use output buffering, the Widget::end call should be made in the same view to avoid breaking the nesting of output buffers.
See also: end()
public static begin ( array $config = [] ) : static
$config array name-value pairs that will be used to initialize the object properties
return static the newly created widget instance
コード例 #1
0
 public static function begin($config = [])
 {
     $widget = parent::begin($config);
     //Когда виджет рендерится вместе с контентом то используется собственный элемент
     //        $widget->element = '#' . $widget->options['id'];
     return $widget;
 }
コード例 #2
0
ファイル: ActiveForm.php プロジェクト: e-frank/yii2-knockout
    public static function begin($config = [])
    {
        $defaults = ArrayHelper::remove($config, 'defaults', []);
        $w = parent::begin($config);
        $w->defaults = ArrayHelper::merge($w->defaults, $defaults);
        $view = $w->getView();
        echo Html::beginForm($w->action, $w->method, ArrayHelper::merge(ArrayHelper::getValue($config, 'options', []), ['id' => $w->id, 'method' => 'POST', 'enctype' => 'multipart/form-data']));
        KnockoutAsset::register($view);
        // client side validate on submit
        if ($w->validateOnSubmit) {
            $view->registerJs(sprintf(<<<EOD
\$('#%1\$s').submit(function(e) {
    var vm = ko.dataFor(e.target);
    if (vm && vm.validate) {
        vm.validate();
    }

    if (vm && vm.isValid && vm.isValid()) {
        return true;
    } else {
        e.preventDefault();
        return false;
    }
})
EOD
, $w->id, Json::encode($w->defaults)), View::POS_END);
        }
        //         $view->registerJs(sprintf(<<<EOD
        // var %1\$s = $.extend({}, x1.config, %2\$s);
        // EOD
        // , lcfirst(\yii\helpers\Inflector::camelize($w->id)), Json::encode($w->defaults)));
        return $w;
    }
コード例 #3
0
 /**
  * @inheritdoc
  * @throws \Exception
  */
 public static function begin($config = [])
 {
     $tree = parent::begin($config);
     if (!$tree->nodes) {
         throw new \Exception('Node is not found');
     }
     return $tree;
 }
コード例 #4
0
 /**
  * @inheritdoc
  */
 public static function begin($config = [])
 {
     static::$raw = true;
     parent::begin($config);
 }
コード例 #5
0
 /**
  * @inherit doc
  */
 public static function begin($config = [])
 {
     $config = self::getConfig($config);
     return parent::begin($config);
 }
コード例 #6
0
ファイル: Yamm.php プロジェクト: bobroid/yamm
 public static function begin($config = [])
 {
     $tthis = parent::begin($config);
     echo Html::tag('header', $tthis->renderLogo() . Html::tag('ul', Html::tag('li', Html::tag('a', $tthis->options['menuLabel'] . Html::tag('span'), ['class' => 'cd-nav-trigger', 'href' => '#cd-primary-nav'])), ['class' => 'cd-header-buttons']), $tthis->options['headerOptions']), '<main class="cd-main-content">';
 }
コード例 #7
0
 /**
  * @param array $config
  * @return ActiveForm
  */
 public static function begin($config = [])
 {
     /** @var $widget static */
     $widget = parent::begin($config);
     return $widget->form;
 }
コード例 #8
0
 public static function begin($config = array())
 {
     parent::begin($config);
 }
コード例 #9
0
ファイル: Modal.php プロジェクト: ivphpan/gwm
 public static function begin($config = [])
 {
     self::$config = ArrayHelper::merge(self::$config, $config);
     self::$config['id'] = uniqid('modal_');
     parent::begin();
 }
コード例 #10
0
ファイル: JSWidget.php プロジェクト: xbazilio/yii2-jswidget
 public static function begin($config = [])
 {
     ob_start();
     return parent::begin($config);
 }
コード例 #11
0
 /**
  * Start widget by calling ob_start(), caching all output to output buffer
  * @see \yii\base\Widget::begin()
  */
 public static function begin($config = [])
 {
     $widget = parent::begin($config);
     ob_start();
     return $widget;
 }