I have a custom content type, I want to capture the URL Alias then modify this and save it as a custom field value, how can I do this?

thanks

Comments

Yogesh Kushwaha’s picture

Please describe your problem in detail so that we can help you.

--
Yogesh Kushwaha

jesterFortyEight’s picture

When my content type is saved I have a required value, if that value does not have a specific format i need to ensure that it is modified

user enters: this-is-my-string

I need to ensure that it is saved as
modified/this-is-my-string

Yogesh Kushwaha’s picture

Sorry for replying too late but I have solution for you. create a custom module and in custom_module.module file write a hook to do this.

function hook_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'your_form_id') {
    $form['#validate'][] = 'mymodule-validate';
  }
}

//function to alter the field value
function mymodule-validate($form, &$form_state) {
  // Random example, if the title is 'test' then modify it
  if ($form_state['values']['title'] == 'test') {
    $form_state['values']['title'] = 'modified/test';
  }
}

Above code will do exactly what you want.

--
Yogesh Kushwaha