views_db_object::add_item() allows for a custom $id to be passed which will then be used for the field machine name. Very useful, but never used in Views itself. I want to add a field in the 'add field' form where the user can enter a custom name that will be used as id. In views_ui_add_item_form_submit() the item is added:

$id = $form_state['view']->add_item($form_state['display_id'], $type, $table, $field);

But there's no way to hook into that little moment. What's the best way to override that $id? I don't want to replace the new item with the same item with a different id later, because then I have to do a lot of id changing. (The generated $id is used in views_ui_add_item_form_submit() itself later on, which I'll then have to undo.)

Is there a way to change the id beforehand, so I don't have to copy Views logic? I don't think overriding class View is an option... or is it?

Comments

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)