function uc_dropdown_attributes_form_uc_object_attributes_form_alter in Dropdown Attributes 8
Implements hook_form_FORM_ID_alter() for uc_object_attributes_form().
File
- ./
uc_dropdown_attributes.module, line 1263 - A module for uc_dropdown_attributes.
Code
function uc_dropdown_attributes_form_uc_object_attributes_form_alter(&$form, $form_state) {
$path = \Drupal::request()
->getpathInfo();
$arg = explode('/', $path);
if (!is_numeric($arg[2])) {
// The form is also used for product class attributes where no changes are
// needed.
return;
}
$node = node_load($arg[2]);
$type = $node
->getType();
$count = \Drupal::database()
->select('uc_class_attributes', 'ca')
->condition('pcid', $type)
->countQuery()
->execute()
->fetchField();
if ($count > 0) {
$link = '/admin/structure/types/manage/' . $type . '/attributes';
$form['attributes']['#empty'] = t('The attributes are defined for the product class <a href="@link">@class</a>', array(
'@link' => $link,
'@class' => $type,
));
}
}