[support] how to make form print on less paper

Ivan Sergio Borgonovo mail at webthatworks.it
Tue Jan 29 22:59:25 UTC 2008


On Tue, 29 Jan 2008 14:43:37 -0500
sander-martijn <lists at severeddreams.com> wrote:

> That's quite simple actually and has nothing to do with drupal.
> Create a print css file and include that.  set display:none on any
> element you don't need and do any other tweaks you need to get it

It won't work. At least it won't be enough and since this stuff is
going to get through an email client I would prefer to avoid relying
on css, not because you can't send them by email... but because you
can't be that sure they will render as you expect.

He has to hide fields conditionally... so he has to apply the css
conditionally and I think the best place should be the theme hook.

I'm guessing Jean has something like:

$output.=drupal_get_form('hisform');
some_mail_function($To,$From,$output);

I'm also guessing that the content of the form is saved somewhere
(DB) so that the content of the form can be reloaded.

function hisform() {
  $result=db_query('....');
  $row=db_fetch_object($result);

  $form['field']=Array(
    '#type'=>'textfield',
    '#default_value'=>$row->somecolumn,
  );
...

}

Unfortunately my first guess was wrong since the theme function
doesn't know about the values in the form.

So hiding fields have to be done in the form function along the line:

$output.=drupal_get_form('hisform','hide');
some_mail_function($To,$From,$output);

function hisform($type) {
  $result=db_query('....');
  $row=db_fetch_object($result);

  $form['field']=Array(
    '#type'=>'textfield',
    '#default_value'=>$row->somecolumn,
  );

/* 
if you use select, checkboxes etc, this part will be more
complicated
*/
  foreach($form as $key => $value) {
    if(is_null($form[$key]['#default_value] && $type='hide' ) {
      $form[$key]['#attributes']=Array('class'=>'ImHidden');
      //or
      //unset($form[$key]);
    }
  }
}

sort of

But some more hints from Jean would help.

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the support mailing list