Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX] Form API: provide a 'type' => 'status_message' element. #3329

Open
klonos opened this issue Oct 19, 2018 · 1 comment
Open

[DX] Form API: provide a 'type' => 'status_message' element. #3329

klonos opened this issue Oct 19, 2018 · 1 comment
Assignees
Milestone

Comments

@klonos
Copy link
Member

klonos commented Oct 19, 2018

Describe your issue or idea

This is related to #1040, but it is not about validation errors, nor is it about how to move the messages produced by backdrop_set_message() within the form (which in D7/Backdrop can be achieved by using '#theme' => 'status_messages' in a form element).

This is to implement something like this respective feature in D8, where this is possible:

$build['status_messages'] = [
  '#type' => 'status_message',
];

This would help in situations where we want to either have static warning/info messages closer to the form elements rather than the top of the page, or to inject such messages in AJAXy thingies loaded in a form. Like this for example:

image

...or this:

image

In the examples above, if there was a "site in maintenance mode" and/or "security updates available" message, we'd still want those at the top of the page, while having the ability to render the status message right above the respective field it relates to.

Steps to reproduce (if reporting a bug)

We should be able to do something like this:

$form['some_form']['some_message'] = array(
  '#type' => 'status_message',
  '#message' => t('Something I need to say'),
  '#message_type' => 'warning',
);

Actual behavior (if reporting a bug)

The above code does not work 😛 ...we need to do tis instead:

$form['some_form']['some_message'] = array(
  '#type' => 'container',
  '#attributes' => array('class' => array('messages', 'warning')),
);
$form['some_form']['some_message']['message'] = array(
  '#markup' => t('Something I need to say'),
);

Expected behavior (if reporting a bug)

The above code should work 😝

Relevant version/system information (if applicable)

@klonos
Copy link
Member Author

klonos commented Oct 19, 2018

...example demonstrating the current problem with using '#theme' => 'status_messages': I am trying to make the "Set up the public files directory..." message be rendered as the rest of the status messages, but when then you could end up with this:

screen shot 2018-10-20 at 8 24 16 am

...^^ the error and warning belong at the top of the page.

@klonos klonos changed the title [DX] Form API: provide a 'status_messages' element. [DX] Form API: provide a 'status_message' element. Oct 19, 2018
@klonos klonos changed the title [DX] Form API: provide a 'status_message' element. [DX] Form API: provide a 'type' => 'status_message' element. Oct 21, 2018
@klonos klonos added this to the 1.x-future milestone Dec 15, 2018
@klonos klonos self-assigned this Oct 10, 2020
@klonos klonos changed the title [DX] Form API: provide a 'type' => 'status_message' element. [DX] Form API: provide a 'type' => 'message' element. May 1, 2023
@klonos klonos changed the title [DX] Form API: provide a 'type' => 'message' element. [DX] Form API: provide a 'type' => 'status_message' element. May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant