Drupal 7 does not catch me css file in form

0

I'm doing a form in Drupal 7, in a custom module created by me.

My module has a name like example_auxiliar_resource (the folder that goes into modules), but then in the .info I specify it correctly: Example Auxiliary Resource .

In a part of the form, injected html code to have a couple of fields in a div, to easily organize it with css. This fragment is in my file example_auxiliar_resource.inc

$form['offer_studies_minimun'] = array(
'#prefix' => '<div class="bloqueprim">
  <div class="estudios">',

'#suffix' => '</div>',  
'#type' => 'select',
'#title' => "Estudios mas adecuados",
'#options' => array(
  0 => t('Selecciona titulacion'),
  1 => t('E.S.O'),
  2 => t('Bachillerato'),
  3 => t('Grado medio de Informatica'),
  4 => t('Grado Superior de Informatica'),
  5 => t('Grado de Ingenieria Informatica'),
  6 => t('Master Informatica'),
),    
);


  $form['offer_studies_especial'] = array(
'#prefix' => '<div class="especialidad">',
'#suffix' => '</div></div>', 
'#type' => 'textfield', 
'#title' => t('Especialidad'),
'#required' => TRUE,
'#default_value' => !empty($form_state['values']['offer_studies_especial']) ? $form_state['values']['offer_studies_especial'] : '',
 );

The css code I want to add is this (to align them horizontally)

div{
width: 200px;
padding: 25px 0;
margin: 0;
}

.main{
background: red;
}

#bloqueprim{  /*padre*/
 overflow: hidden;
 width: 100%; 
}
#bloqueprim .estudios, #bloqueprim .especialidad{  /*hijos*/
 display: inline-block;
}

As I have seen in the documentation, there are different ways of doing it. Since I am in drupal 7, the method drupal_add_css() continues to work. But none of the methods work for me.

I've tried with:

drupal_get_path('module', 'example_auxiliar_resource') . 'css/style.css';

at the beginning of the page. (from the .inc code) I've also put it in the .info as is, but still not going.

I've also tried

$form['#attached']['css'] = array(
 drupal_get_path('module', 'example_auxiliar_resource') . 'css/style.css',    
);

inside the form, and it does not go. And a couple of other ways that have also failed me.

What am I doing wrong?

    
asked by Extermis 19.09.2017 в 13:49
source

1 answer

0

In the .info of your module you must include this line

stylesheets [all] [] = tuarchivo.css

Where it says 'tuarchivo.css' replace it with the path where your CSS file is located, which should be inside the root folder of the module

I'll give you an example link

    
answered by 21.09.2017 в 14:14