Skip to content

Commit

Permalink
Add help text to "Add Planting" form with link to Planting quick form.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstenta committed Mar 15, 2024
1 parent db78886 commit fced3ea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions farm_crop_plan.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\farm_crop_plan\Bundle\CropPlanting;

/**
* Implements hook_help().
*/
function farm_crop_plan_help($route_name, RouteMatchInterface $route_match) {
$output = '';

// Add a link to the Planting quick form on the "Add planting" form, if the
// module is installed.
if ($route_name == 'farm_crop_plan.add_planting' && \Drupal::moduleHandler()->moduleExists('farm_quick_planting')) {
$quick_planting_url = Url::fromRoute('farm.quick.planting', ['plan' => $route_match->getParameter('plan')->id()])->toString();
$output .= '<p>' . t('Tip: Use the <a href=":url">Planting quick form</a> to create a plant asset. You will be redirected back here to fill in more details for the plan.', [':url' => $quick_planting_url]) . '</p>';
}

return $output;
}

/**
* Implements hook_entity_bundle_info_alter().
*/
Expand Down

0 comments on commit fced3ea

Please sign in to comment.