Last active
November 8, 2020 11:39
-
-
Save ZombiMorgan/fa5cfa32ddba7cb396d4f99e17ed28c0 to your computer and use it in GitHub Desktop.
validate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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']; | |
| } | |
| if ($value != $sum) | |
| $form_state->setErrorByName('field_value', 'Проверьте сумму, должна быть: ' . $sum); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment