ng-admin
ng-admin copied to clipboard
Align several fields on same row?
Let's consider the following form:
It would be great to be able to align several fields on the same row:
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.
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.
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.
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.
Any hint on how to do this?
Until we decide to do this, you can always override the edition view template (see Customizing The View Template For A Given Entity)
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 This feature looks really promising, thanks a lot! :+1:
@F3L1X79 follow #657