Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $category = $fieldSet->addField(
- 'category_id', 'select', [
- 'name' => 'category_id',
- 'label' => __('Category'),
- 'required' => true,
- 'values' => $this->_selectedCategories->toOptionArray(),
- ]
- );
- $url = $this->_urlInterface->getUrl('homepage/ajax/getcategoryurl');
- $category->setAfterElementHtml('
- <script>
- require(['jquery'], function($){
- var customUrl =
- $("#category_id").on('change', function () {
- $.ajax({
- url: '<?= $url; ?>',
- type: 'POST',
- data: {category_id: $(this).val(), form_key: window.FORM_KEY},
- success: function (response) {
- $("#url").val(response['content']);
- }
- });
- });
- });
- </script>
- ');
- url: '<?= $url; ?>'
Add Comment
Please, Sign In to add comment