开发者

how to make this drupal module

开发者 https://www.devze.com 2023-02-26 03:03 出处:网络
hello i have an form with text and search button it work but it i need to search bar and the button on the same line not on line by line

hello i have an form with text and search button it work but it i need to search bar and the button on the same line not on line by line

my code

 $form['search'] = array(
    '#type' => 'textfield',
    #size' => 30,
    '#maxlength' => 255
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' =开发者_开发知识库> t('Search'),
  );


You shouldn't need to do anything in the PHP code to achieve this; you should be able to do it using CSS stylesheets.

I'd suggest using CSS display:inline; or display:inline-block; on the <div> wrapper element that Drupal creates for its form elements.

Hope that helps.

[EDIT]

Something like this:

.form-item#search, .form-item#submit {
    display:inline;
}

..in your module's or theme's CSS file.


You can also wrap your fields in an in-line fieldset given below:

$form['filter'] = array(
'#type' => 'fieldset', 
'#title' => t('Filter options'), 
'#attributes' => array('class' => array('container-inline')), 
);
$form['filter']['search'] = array(
'#type' => 'textfield',
'#size' => 30,
'#maxlength' => 255
);
$form['filter']['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
0

精彩评论

暂无评论...
验证码 换一张
取 消