PHP code example of urichalex / yii2-dadata-widget
1. Go to this page and download the library: Download urichalex/yii2-dadata-widget library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
<?= $form->field($model, 'inn')->widget(DadataWidget::class, [
'apiKey' => 'your apiKey',
'customAttributes' => [
// key - model attribute name or form field name, value - attribute from response from service
'city' => 'city_with_type',
// Value can be an array
'house' => [
'attribute' => 'house_with_type', // Dadata response attribute name (response.data.house_with_type)
'selector' => '#my_input_id', // Form field selector to write the value to
'createHiddenField' => true, // create hidden field
'value' => $someValue, // set hidden field value
'fieldOptions' => [ // some field html options
'class' => 'myClassName',
'data-attribute' => 'value'
]
],
],
])
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.