Size: a a a

2020 August 10

T

TradersVE in Yii Framework 3
Suppose that the dynamic part is the language of the application, assuming it is multilanguage, I would pass the parameter through the controller and it would work.
источник

T

TradersVE in Yii Framework 3
Now talking about ajax, or js?
источник

AP

Arman Poghosyan in Yii Framework 3
Ok, but how am I supposed to set it for each field separately. I can change the template in factory, but I need to specify dynamic part in that template, which will be set for each field separately.
источник

AP

Arman Poghosyan in Yii Framework 3
I'm not sure we are talking about the same thing.
источник

А

Алексей R in Yii Framework 3
@samdark только что мудохался с тем, что ListenerCollection::add не сохраняет список слушателей. Оказалось, что метод иммутабельный. А по имени и не скажешь ) и пример в доке такой, что тоже не намекает
источник

AP

Arman Poghosyan in Yii Framework 3
TradersVE
Suppose that the dynamic part is the language of the application, assuming it is multilanguage, I would pass the parameter through the controller and it would work.
I just have '{input}{text}' template for example, and I want to have a way to define {text} part later on for each field individually.
источник

AP

Arman Poghosyan in Yii Framework 3
Similar to the way $field->label('somelabel') is applied, but my custom part
источник

T

TradersVE in Yii Framework 3
Arman Poghosyan
Similar to the way $field->label('somelabel') is applied, but my custom part
for example:

   'app' => [
       'nav' => [
           'guest' => [
               ['label' => 'Sing up', 'url' => '/registration/register'],
               ['label' => 'Sing in', 'url' => '/auth/login'],
           ],
           'logged' => [
               [
                   'label' => '<div class = "is-user-avatar">{logo}</div>' .
                              '<div class = "is-user-name"><span>{username}</span></div><span class="icon"></span>',
                   'items' => [
                       [
                           'label' => 'Profile',
                           'url' => '/setting/profile',
                           'icon' => 'mdi mdi-account',
                           'iconOptions' => 'icon'
                       ],
                       [
                           'label' => 'Setting Account',
                           'url' => '/setting/account',
                           'icon' => 'mdi mdi-settings',
                           'iconOptions' => 'icon'
                       ],
                       '-',
                       [
                           'label' => 'Logout',
                           'url' => '/auth/logout',
                           'icon' => 'mdi mdi-logout',
                           'iconOptions' => 'icon'
                       ]
                   ],
                   'options' => ['class' => 'has-dropdown-with-icons has-divider has-user-avatar'],
                   'encode' => false,
               ]
           ]
       ],
источник

T

TradersVE in Yii Framework 3
its config nav widget in logged have {logo}{username}.

if (isset($identity) && $identity->getId() !== null) {
   $navConfig['brand()'] = [$app->get('app.navBar.brand')];
   $navConfig['menuOptions()'] = [['class' => 'navbar-menu fadeIn animated faster', 'id' => 'navbar-menu']];
   $navConfig['options()'] = [['class' => 'navbar is-fixed-top']];
   $navConfig['toggleIcon()'] = ['<span class="icon"><i class="mdi mdi-forwardburger mdi-24px"></i></span>'];
   $navConfig['toggleOptions()'] = [['class' => 'navbar-item is-hidden-desktop jb-aside-mobile-toggle']];

   if ($app->get('app.nav.logged') !== []) {
       $menuItems = $app->get('app.nav.logged');
   }

   $label = '';

   foreach ($menuItems as $key => $item) {
       $label = strtr($item['label'], [
           '{logo}' => Html::img($aliases->get('@web/images/icon-avatar.png')),
           '{username}' => $identity->getIdentity()->username
       ]);

       if ($label !== '') {
           $menuItems[$key]['label'] = $label;
       }
   }
} else {
   $menuItems =  $app->get('app.nav.guest');
}
?>

<?= NavBar::begin($navConfig)->start(); ?>

   <?= Nav::widget()
       ->currentPath($url->generate($urlMatcher->getCurrentRoute()->getName()))
       ->items($menuItems)
   ?>

<?= NavBar::end();
источник

T

TradersVE in Yii Framework 3
username change dinamic
источник

T

TradersVE in Yii Framework 3
example for nav widget screen.
источник

AP

Arman Poghosyan in Yii Framework 3
If I follow your code correctly, you just set contents of the label while configuring. Have a look at https://github.com/yiisoft/form/issues/17#issuecomment-671565268
источник

AP

Arman Poghosyan in Yii Framework 3
Terabytesoftw Also as far as I see your example is for custom widget. But I'm talking about reusing Field widget as it is ok and I need just small part to be dynamic.
источник

T

TradersVE in Yii Framework 3
Arman Poghosyan
Terabytesoftw Also as far as I see your example is for custom widget. But I'm talking about reusing Field widget as it is ok and I need just small part to be dynamic.
It's normal yiisoft/yii-bulma widget is not custom, just configure it.
источник

T

TradersVE in Yii Framework 3
Well you can add a dynamic tag method to widgets, it can be good.
источник

T

TradersVE in Yii Framework 3
$field->config($form, 'email')
   ->label(false)
   ->textInput(['required' => true])
   ->dinamicTags(['template', ['{dynamic}' => 'Here goes dynamic contents']])
источник

AP

Arman Poghosyan in Yii Framework 3
Yes, but I just want to point out that I don't need custom widget. Yes, I know I can do anything in my widget. But I'm just using Yiisoft\Form\Widget\Field which is ok by itself. And we were discussing that it is not extendable. I just want to have a dynamic part in it. So for that you are proposing to create my widget, copy paste all the code from Yiisoft\Form\Widget\Field and add my custom part there afterwards.
источник

AP

Arman Poghosyan in Yii Framework 3
But I propose just to add a way of defining dynamic (custom) parts to Yiisoft\Form\Widget\Field to make it more extendable.
источник

T

TradersVE in Yii Framework 3
Well, but I like the idea of the dynamicTags, to make a method, passing the place where it will be replaced and the value, it would be very good.
источник

AP

Arman Poghosyan in Yii Framework 3
If you are ok with my points mentioned in issue (1-6), I will prepare PRs for them (each separately).
источник