Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frederickjh/17a1df41a749041ce1d4 to your computer and use it in GitHub Desktop.
Save frederickjh/17a1df41a749041ce1d4 to your computer and use it in GitHub Desktop.
Code from slide 47 of "Tailor your backend to meet the clients needs" - Improve the URL selection form
<?php
/** Text from slide 47 of "Tailor your backend to meet the clients needs"
* http://www.slideshare.net/stevenvdhout/durable-drupal-backend
* Improve the URL selection form
**/
if (isset($form['#entity_type'])
&& $form['#entity_type'] == 'node'
&& isset($form['path'])
&& isset($form['path']['alias'])) {
unset($form['path']['#type']); // remove the fieldset
unset($form['path']['alias']['#description']);
$form['path']['alias']['#title'] = '<strong>' . t('Path') . ':</strong> ';
$form['path']['alias']['#title'] .=
(isset($_SERVER['HTTPS'])) ? 'https://' . $_SERVER['HTTP_HOST'] . '/' : 'http://' . $_SERVER['HTTP_HOST'] . '/';
if (isset($form['path']['pathauto'])) {
$form['path']['alias']['#states'] = array();
if (!$form['path']['alias']['#default_value']) {
$form['path']['alias']['#attributes'] = array('placeholder' => '<' . t('magically generated') . '>');
}
$form['#submit'][] = 'ux_pathauto_submit';
// remove the group variable, so it does not get rendered in the fieldset below
unset($form['path']['#group']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment