function organigrams_vocabulary_form_submit in Organigrams 8
Same name and namespace in other branches
- 8.2 organigrams.module \organigrams_vocabulary_form_submit()
Custom submit function for the vocabulary add form.
Parameters
array $form: Contains the vocabulary add form.
\Drupal\Core\Form\FormStateInterface $form_state: Contains the form state of the vocabulary add form.
1 string reference to 'organigrams_vocabulary_form_submit'
- organigrams_form_alter in ./
organigrams.module - Implements hook_form_alter().
File
- ./
organigrams.module, line 142 - Extends Taxonomy to create organigrams.
Code
function organigrams_vocabulary_form_submit(array $form, FormStateInterface $form_state) {
// Get the vocabulary id.
$vid = $form_state
->getValue('vid');
// Create taxonomy fields.
organigrams_create_term_fields($vid);
// Get the vocabulary entity.
$vocabulary = $form_state
->getFormObject()
->getEntity();
// Check if it exists.
if (!empty($vocabulary)) {
// Get the form values and iterate through them.
$form_values = $form_state
->getValues();
foreach ($form_values as $key => $value) {
// Add the field and value to the third party settings if the prefix
// is 'organigrams_'.
if (substr($key, 0, 12) == 'organigrams_') {
$vocabulary
->setThirdPartySetting('organigrams', $key, $value);
}
}
// Save the entity.
$vocabulary
->save();
}
}