This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Correct way to add '#element_validate' callback to a form element

When I look through core code adding #element_validate callbacks to form elements, I see several different ways it is done:

REST API create user with role, language

I'm generating users via REST API and I want to assign both the user role and preferred language upon creation.

I'm unable to find any information on the body content format.

const body = {

'name': [{'value': name}],

'mail': [{'value': email}],

'pass': [{'value': password}],

'roles': [{'target_id': 'user'}],

'preferred_language': [{'value': 'en'}]

};

What is the proper format for 'Roles' and 'Preferred Language'. 

Users generate fine if I don't try creating the role or language.

Default MySQL field value in BaseFieldDefinition settings

Dear Drupal community,

We need to set default MySQL values on schema creation, for example:

`type` int(10) UNSIGNED NOT NULL DEFAULT 6

We have seen that you can set the default value if you use schema definition using the 'default' key but not using the BaseFieldDefinition class. Is this a bug or a feature? 

For example for int we would have to define the default value in 'core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php' we would add  in schema() the line:

Chart data stored in a database table (dynamically) in Drupal 8

I found these instructions for using the Charts module to display data from a database for Drupal 7:
https://www.drupal.org/docs/8/modules/charts/charts-howtos/chart-some-data-stored-in-a-database-table-dynamically

Has anyone tried this in Drupal 8? Are there any instructions for doing this in Drupal 8? Thanks!

how to access $form_state object inside a custom service class which extends a core module service

Hi,

I'm using D8 lightning distribution.

I created a custom service extends a core module service in my module and also a custom form.

When this form submitted, the customer service class method will be called before the submitForm method. And I need to do something in this service class method but it needs data from the $form_state object.

I don't know how to access $form_state object in my custom service class. How can I do this?

Thank you!

Multivendor

I need to Multivendor modul for my sit

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions