1

I am very new to Drupal. I have an html form and I want to create a module that take the html of the form and create a table in the database and saves the form values in database.

what i have done i have created a form with form api (with buildForm method) my form is being rendered and i have converted it into Twig template (it is being shown in twig template), but first my CSS is not getting loaded.

My library file: mymodulename.libraries.yml

bootstrap:
  version: 1.x
  css:
    css/bootstrap.min.css: {}
  js:
    js/bootstrap.min.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

global-components:
  Version: 1.x
  css:
    css/baselayout.css: {}
    css/form.css: {}
    css/wisdom.css: {}

  js:  
    js/jquery.smartmenus.min.js: {}
    js/custom.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
  • I removed the second unrelated question (about database input), please ask separate questions separately, after researching yourself first. Thanks! – Clive Nov 29 '17 at 13:41
1

CSS lives one level further down in a libraries file; under system, module or theme. e.g.:

bootstrap:
  version: 1.x
  css:
    theme:
      css/bootstrap.min.css: {}
  js:
    js/bootstrap.min.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
  • i tried this also – gulshan Nov 29 '17 at 13:20
  • That's the answer to your question (how to add css to module in drupal 8), beyond that I'm not sure what you mean – Clive Nov 29 '17 at 13:33
  • hi Clive please help me how to pass action attribute in twig form. – gulshan Dec 2 '17 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.