Categories
CMS Drupal Mastering Development

How do I add a button with a custom redirect to a node view?

I’d like to add a "More info" button to the bottom of a node view. The button should redirect the user to a URL based on the current node, e.g. node/1/info: /** * Implements hook_node_view * * Add the "More Info" button to idea content */ function implementations_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { […]

Categories
CMS Drupal Mastering Development

Forms API: How can I specify which submit action is the default?

I have a custom form, with two different submit actions. Here’s my code (edited for brevity): class EditSlideshow extends FormBase { public function buildForm(array $form, FormStateInterface $form_state) { $form[‘actions’][‘delete’] = [ ‘#type’ => ‘submit’, ‘#value’ => t(‘Delete Slideshow’), ‘#submit’ => [‘::submitDelete’], ‘#validate’ => [‘::validateDelete’], ‘#attributes’ => [‘class’ => [‘btn’, ‘btn-blue’]], ]; $form[‘actions’][‘submit’] = [ ‘#type’ […]