I am getting the following error:
Warning: Missing argument 1 for Drupal\custom_forms\Service\CustomFormsService::__construct(), called in /drupal/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 264 and defined in Drupal\custom_forms\Service\CustomFormsService->__construct() (line 13 of modules/custom_forms/src/Service/CustomFormsService.php).
And my code (service.php
) is:
public function __construct($request) {
$this->cityname = \Drupal::request()->get('cityname');
if($this->cityname != ''){
$result = \Drupal::database()->select('city_municipality','cm')
->fields('cm',array('municipality'))
->condition('city', $this->cityname)
->execute()->fetchAll();
$result = json_encode($result);
print $result;
exit;
}
custom_forms_services.yml
services:
custom_forms.custom_forms_service:
class: Drupal\custom_forms\Service\CustomFormsService
But the form functionalities are working fine.
Can anyone help me out on this?