Skip to content

Instantly share code, notes, and snippets.

@ZombiMorgan
ZombiMorgan / projects.php
Last active November 8, 2020 11:39
validate
<?php
function projects_node_project_form_validate(&$form, FormStateInterface $form_state) {
// $project = $form_state->getFormObject()->getEntity();
$value = $form_state->getValue(['field_value', '0', 'value']);
$sum = 0;
// $status = $form_state->getValue(['field_status', '0', 'value']);
foreach ($form_state->getValue('field_investors') as $index => $item)
if (is_numeric($index)) {
$sum += $item['subform']['field_contribution']['0']['value'] + $item['subform']['field_contribution_over']['0']['value'];
<?php
namespace Drupal\projects\Plugin\Block;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Block\Annotation\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;