Posted by monaw on November 2, 2014 at 6:12pm
I am using DS 2.6 and I want to place a simple markup programmatically in my custom node edit form. I can get the markup to show up but it shows at the bottom while I want it at the top. I tried setting the #weight for the form item but it seems this does not work for DS controlled views. It works if I don't use DS to control that display.
So, my question is how can I programmatically place my form item in a particular region and order?
This is for Drupal 7.27 (yea I need to do the security upgrades...)
Comments
Upgraded to 2.7 but problem remains
I saw an issue related to this (https://www.drupal.org/node/2035531) and a patch. The latest version 2.7 was released after the issue's patch so I upgraded to 2.7 but that did not fix the problem for me ):
How to programmatically place fields in display suite display?
I just wanted to add that I'm looking to do the same thing. Would appreciate any hints from anyone who has been able to figure this out. Thanks.
Also looking to do the same
I have attached a profile2 form to the user account form where the display is managed with ds forms and a 2col layout. The user account form is rendered in the 2col layout but obviously the profile2 fields are not, it's on the page below the ds layout. I would like to programmatically render the profile2 forms inside the .group-right of the ds layout.
@davewilly FWIW I just added
@davewilly FWIW I just added fields to the user entity and used ds forms to arrange them on the edit form and ds to arrange them on the view screen. You can use hook_form_user_profile_form_alter and hook_form_user_register_form_alter to further control the forms. I didn't use profile2 as I didn't know about it at the time! It depends on what you are trying to do whether my solution would work for you.
I have managed to proof what
I have managed to proof what I need to do by slightly modifying a module function, now I'm trying to use the API but hook_ds_pre_render_alter only fires for ds layouts when viewing content, and not on forms. I know what I need to do, but haven't quite worked out how to do it without modifying the module, and we don't do that, so back to drawing board if the API is no help.
Just a suggestion but have
Just a suggestion but have you enabled ds_forms? Don't know if that would make any difference?
Yes that's all done, and the
Yes that's all done, and the account form is being displayed successfully using ds forms, but I also need to get the profile2 form into one of the regions which is what I'm battling with at the moment. Since the profile2 form cannot be managed by ds forms on the account form (as it's a separate form which is attached with profile2_attach_form), I'm trying to preprocess the render and move it into the region. Just can't find a hook or function to override, yet!
Go there in the end
So, if you need to merge a profile2 form into the user account form which is displayed using ds forms, and you'd like the profile2 form to appear in one of the regions you will need to do this:
Override the ds_forms_custom_form preprocess function with your own modified version of the original function:
function MYMODULE_theme_registry_alter(&$theme_registry) {// Override the theme preprocess function in ds_forms.module with our own
$theme_registry['ds_forms_custom_form']['preprocess functions'][0] = 'myfunction_ds_forms_custom_form';
}
Then in your function you want to add your form or field to the layout settings:
function myfunction_ds_forms_custom_form(&$vars) {
.....
// If we have a profile2 form attached to the account form, add it to the right region
if(isset($form['profile_staff'])) {
$layout['settings']['regions']['right'][] = 'profile_staff';
}
......
// Create region variables based on the layout settings.
foreach ($layout['regions'] as $region_name => $region) {....
Hope that saves someone some time.