S
S
Sergey Beloventsev2017-09-04 18:26:39
Yii
Sergey Beloventsev, 2017-09-04 18:26:39

How to get element attribute in extension?

I want to create an extension of this plugin for yii2, but I need to get the id attribute of the used field, relatively speaking
<?= $form->field($model, 'datapicker')->widget(Datapicker::classname(), [...]) ; ?>
I need to get the id of this field. Don't tell me how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-09-04
@Sergalas

well, in the widget:

echo $this->id;
echo $this->counter;
echo $this->autoIdPrefix;

or
$this->autoIdPrefix = 'mySuperWidget';
echo $this->id;

See what you need. Here is the dock: www.yiiframework.com/doc-2.0/yii-base-widget.html Your widget is inherited from yii\base\Widget, which means that all the charms and methods are available to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question