ng-admin icon indicating copy to clipboard operation
ng-admin copied to clipboard

Align several fields on same row?

Open jpetitcolas opened this issue 9 years ago • 7 comments

Let's consider the following form:

image

It would be great to be able to align several fields on the same row:

angular admin

It may be done introducing a new nga.row function. We may then add fields to it, and templates would render it in a single div.row element, with each size automatically computed (3 elements, 12 columns => div.col-md-4) unless specified.

What do you think of it?

We can already do it using custom template, but it requires to create new templating-purposed only directive to embed several fields. Pretty cumbersome and not optimal IMO.

jpetitcolas avatar May 20 '15 07:05 jpetitcolas

Your second screenshot is really interesting: the label "first name" is at the same distance from the first and second form input. Users may have troubles dermining which input it concerns.

If we want to go down the multiple inputs per row path, I believe the GridForms layout is better.

image

As for how to make this configurable, I don't like the idea of a row function. Instead, a length function called on the field would set up the input length one by one; during rendering, if the sum of past renderer input lengths exceeds the max length of a row, we start a new row. This way, no need for a row function.

Example:

  • field 'foo' has length 5
  • field 'bar' has length 5
  • field 'baz' has length 2
  • field 'foobar' has length 12

Each row haw maxlength 12

So we'll render row 1 with 'foo', 'bar', and 'baz', and line 2 with 'foobar'.

Not sure it's easy to achieve with Angular.js, but the way to go IMO.

fzaninotto avatar May 20 '15 07:05 fzaninotto

For the second screenshot, it has been made quickly on Gimp. But it may indeed be an issue. A solution may be to add an extra left padding to labels. Or perhaps should we add a col-md-offset. It would prevent from adding an extra dependency to GridForms.

:+1: with your solution of field lengths.

jpetitcolas avatar May 20 '15 08:05 jpetitcolas

Any hint on how to do this?

manuelnaranjo avatar Jul 10 '15 18:07 manuelnaranjo

Until we decide to do this, you can always override the edition view template (see Customizing The View Template For A Given Entity)

fzaninotto avatar Jul 13 '15 13:07 fzaninotto

I started working on a fieldset field type, which can then have a series of fields associated. I made some progress on this, will fork and push it once I made some more progress.

manuelnaranjo avatar Jul 13 '15 13:07 manuelnaranjo

@manuelnaranjo This feature looks really promising, thanks a lot! :+1:

F3L1X79 avatar Sep 08 '15 12:09 F3L1X79

@F3L1X79 follow #657

manuelnaranjo avatar Sep 08 '15 12:09 manuelnaranjo