It would be good if dialogs with forms in them could have a configurable options array for things like size, position etc.... I started to look into this but only got part-way there so i am posting a patch in the hope that someone else will pick it up and continue to work on it as i dont have a lot of time at the moment.

My patch, carrys the options through the form rendering functions so they are output into the JS. The form will actually resize if you do -

    $options = array('width' => 1000);
    
    $form_state = array(
      'ajax' => TRUE,
      'title' => $title,
    );
    $output = dialog_form_wrapper('form_id, $form_state, $options);
    ctools_ajax_render($output);

The problem is that the loading display sticks to it's width of 600px. When the form is loaded into the dialog, the dialog then expands to the width above (1000px). Ideally, you would want the dialog to open at 1000px, but i could not see an easy way initially to build this into the loading function. As i say i dont have a lot of time to delve right into the code, so posting this in the hope that someone else can progress with the patch.

Comments

blairski’s picture

StatusFileSize
new1.29 KB

I have updated this patch to work with the latest dev snap shot of the Dialog module.

mirzu’s picture

I rolled a simular patch and would switch to this implementation if this change made it into the module.

timcosgrove’s picture

StatusFileSize
new723 bytes

I ran into this situation today myself, and came up with the attached solution. The patch posted above at http://drupal.org/node/799040#comment-3459082 is cleaner, but doesn't work with dialog_get_form; and since dialog_get_form already pushes any extra args into $form_state['args'], we can't change dialog_get_form to have $options as a third argument. This patch allows the dialog options array to be passed in as an additional array of the form

array('dialog_options' => array('option1' => 'value1', 'option2' => 'value2'))

This solution also works with calling dialog_form_wrapper directly; just add the array to your $form_state.

Thoughts?

sitiveni’s picture

I've applied your patch Tim, thanks for that, it's very useful.

There's a strange behavior though when adding the option resizable. It seems at first as I could control this option by adding it into the form_state['args'], but it somewhat resets itself again when opening another dialog window.

As an explanation: I'm having all user login forms (that is login, registration, forgot password, reset password) as dialog forms (dialog_get_form). These forms are connected with each other by links, so I can switch form the login form directly to registration or forgot password. Now, when I've got the resizable option, every second form displays the resize corner (and the form is resizable).

Example: first time I open the login form, no resize. Switching by link to forgot password form, the resize corner is available. Going then to password reset form, no more resize. Jumping back to login form, resize is here again.

What could cause this behavior? Is there some sort of reset to default while displaying the loading window? I also make use of the width option; works perfectly on every from.

These are the dialog options I set:

  // Dialog window options
  $form_state['args'][] = array(
    'dialog_options' => array(
      'width'     => '310px',
      'resizable' => false,
    ),
  );
devin carlson’s picture

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

Dialog 6.x is no longer supported.