Set custom Dev Portal App attribute via input param

fishbd1
Participant II

I have added custom attribute on the Dev Portal Application called API Title (aka Model Name in Management UI).

I've added a custom API Summary screen that displays a Swagger UI, the product associated with the model, a downloadable swagger and a Register Now Button that will redirect to the Register App page and append the model name as a parameter. (ie. https://domain.com/user/me/apps-to-api-direct/add/Docusign_1?)

What I would like to do is take the appended API Model (Docusign_1) in the URL and set it in the Dev Portal Application attribute API Title. Very similar to a contextual filter in drupal views. I know this will take some custom work within the Devconnect Modules, but I need some assistance in determining where to set those custom attributes in the Dev Portal App.

Any assistance would be GREATLY appreciated.

4689-register-with-api.png

4690-add-app.png

Solved Solved
1 2 409
1 ACCEPTED SOLUTION

@Dave ,

It should be simple, Just do form alter in a custom module of above form, Read the param using below code,

$api_title = arg(4);

Set the attribute default value by altering the form using hook_form_form_id_alter,

function YOURMODULE_form_FORMID_alter(&$form, &$form_state, $form_id) {
	
}

For example,

function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'devconnect_developer_apps_edit_form') {
        $form['attribute_API%20Title']['#default_value'] = arg(3);
    }
}

4692-screen-shot-2017-04-18-at-30344-pm.png

Hope it helps, Keep us posted if any.

View solution in original post

2 REPLIES 2

@Dave ,

It should be simple, Just do form alter in a custom module of above form, Read the param using below code,

$api_title = arg(4);

Set the attribute default value by altering the form using hook_form_form_id_alter,

function YOURMODULE_form_FORMID_alter(&$form, &$form_state, $form_id) {
	
}

For example,

function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'devconnect_developer_apps_edit_form') {
        $form['attribute_API%20Title']['#default_value'] = arg(3);
    }
}

4692-screen-shot-2017-04-18-at-30344-pm.png

Hope it helps, Keep us posted if any.

@Dave , If your query is resolved, Please click on accept link below the answer so that it's helpful for others. If not, Keep us posted.