This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Drupal 8 - How to make ajax calls from custom block?

I have a custom module that creates a block. This block is a chat that interacts with an external service through an API.

When the user sends a message through the chat, jQuery takes the message and sends it using $.ajax() to submit.php which then does all the handling to get the response from the API and returns in back to jQuery to be displayed to the user.

Now all of this is in theory, since I haven't been able to find a way to get the correct path to that submit.php file.

Page title for custom entity is not working

I have a custom entity and I want to show entity title using two concatenated fields.

I have implemented the label method within the definition of my custom entity class:

public function label() {
$obra = $this->get('idobra')->entity;
$ordem_servico_label = format_string('@obra-@sequencial', [
'@obra' => $obra->label(),
'@sequencial' => $this->get('sequencial_obra')->value
]
);
return $ordem_servico_label;
}

Using GeoPHP in custom Form

Hi Forum,

i want to use the geoPHP library in a custom form, i´ve installed the lib with the geofield. Now i added:

use GeoPHP\GeoPHP;

and in my validateForm:

public function validateForm(array &$form, FormStateInterface $form_state) {
		$geom = \geoPHP::load('MULTILINESTRING((10 10,20 20,10 40))','wkt');
...

but i get the errorm that the  Error: Class 'geoPHP' not found. For which keywords i have to google?

best regards

Andy

Need help with a simple custom service with form builder - You have requested a non-existent service

Hi Guys,

i am trying to make simple custom services with dependency injunction + ajax form. when i am trying to include custom service to my form builder class with help of dependency injunction, i am getting the following error. can you any one help me. i am new for Drupal.

Error:

[SOLVED] Drupal 7 - node state in submit callback function

Hi,

I want to copy / clone a field to another node field when I save a node.
Example : 

$node_1->field_1 = $node_2->field_1;
node_save($node_1);

I have added a new submit function with hook_form_alter()

Drupal 8 Commerce 2 get Item from order

Hi, 

I use Drupal 8 and Commerce 2, I have standard Drupal shipping, have 2 types of product “default” and “downloadable” and set standard shipping in Drupal 8 and Commerce 2.   

I have 2 question now: 

  1. How I can get product types in order. 
  2. How I can programmatically get info (name, cost and etc) for shipping in order. 

Now I use: 

$order = Order::load(1);

foreach ($order->getItems() as $key => $order_item) {

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions