Robin S

Template Field Widths

Recommended Posts

Another little admin helper module...

Template Field Widths

Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

screencast

Why?

When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.

Installation

Install the Template Field Widths module.

Config options

  • You can set the default presentation of the "Field widths" field to collapsed or open.
  • You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover.
  • You can choose to show the original field width next to the template context field width.

 

https://github.com/Toutouwai/TemplateFieldWidths
https://modules.processwire.com/modules/template-field-widths/

  • Like 22

Share this post


Link to post
Share on other sites

Cool! Add an arrows-h icon to the InputfieldMarkup? Make the widths with the slider instead of text input? Dynamically show the width of fields as they change?

  • Like 2

Share this post


Link to post
Share on other sites

@matjazp, thanks for the suggestions.

42 minutes ago, matjazp said:

Add an arrows-h icon to the InputfieldMarkup?

Yes, done in v0.1.2

42 minutes ago, matjazp said:

Make the widths with the slider instead of text input?

Sorry, no, if I'm wanting numbers to sum to exactly 100 then I much prefer a number input than a slider. Just tab from field to field and it's very quick.

42 minutes ago, matjazp said:

Dynamically show the width of fields as they change?

Great idea, done in v0.1.2

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, Robin S said:

Another little admin helper module...

...with a not so little impact when building complex sites. I already know I'm going to use this a lot 🙂 Thank you!

  • Like 3

Share this post


Link to post
Share on other sites

Very nice 😍

I used to have a separate template and output everything in a HTML table. Just to get an overview of it. But this is much better!

How about putting the original with in a light gray somewhere? I am always interesetd wether I changed the value in template context or not.

  • Like 2

Share this post


Link to post
Share on other sites

Seriously brilliant @Robin S - this is going to be an absolutely huge timesaver!

I think this deserves a screencast in the first post showing the layout change dynamically as percentages are adjusted - so cool!

  • Like 2

Share this post


Link to post
Share on other sites

What do you think about having fieldsetTabs actually separated out into tabs in the editing interface - I think this would be a really helpful addition.

  • Like 1

Share this post


Link to post
Share on other sites
On 11/22/2018 at 9:11 PM, Klenkes said:

How about putting the original with in a light gray somewhere? I am always interesetd wether I changed the value in template context or not.

Personally I would find that more distracting than useful, but will look at adding it as a configurable option.

On 11/23/2018 at 7:48 AM, adrian said:

What do you think about having fieldsetTabs actually separated out into tabs in the editing interface - I think this would be a really helpful addition.

I can see why this would be good, but I wouldn't want to lose the ability to use the tab key to move through all fields in the template. Will do some experimenting and see if it's possible to keep the tab key navigation in a tabbed interface - I have a feeling that hidden inputs may not be focusable with tab.

Share this post


Link to post
Share on other sites
2 minutes ago, Robin S said:

I have a feeling that hidden inputs may not be focusable with tab.

Tabbing works find in the PW admin when editing a page - you can use the tab key to move between fields in any of the WireTabs - Content, Custom tabs, Settings, etc. Maybe I am not understanding the issue you are referring though ?

Share this post


Link to post
Share on other sites
1 minute ago, adrian said:

Tabbing works find in the PW admin when editing a page - you can use the tab key to move between fields in any of the WireTabs - Content, Custom tabs, Settings, etc. Maybe I am not understanding the issue you are referring though ?

My objective is to avoid needing to mouse to and click anything in the "Field widths" field. Right now I can use the tab key to move through all the fields, but if some fields are inside a hidden tab content div then I suspect it may be quite difficult to keep this functionality. If it were just a matter of showing the tab content with the focused field that would be fairly simple, but I suspect the browser will refuse to focus an input inside a hidden div (I haven't checked yet).

In the PageEdit/WireTab example, PW will not move focus from the last field in Tab A to the first field of Tab B using the tab key.

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Robin S said:

In the PageEdit/WireTab example, PW will not move focus from the last field in Tab A to the first field of Tab B using the tab key.

Of course - sorry, I didn't realize that was a goal. I guess I thought it would be ok to use the mouse to activate the other tab.

Perhaps an alternative would be to just separate out other tabs below the main Content tab so they are separate. I just think this would help with visualizing the layout better, because at the moment it looks like the fields in other tabs are all part of the one form, which of course they are not, visually speaking.

Anyway, not a big deal 🙂

Share this post


Link to post
Share on other sites

v0.1.3 adds a tabbed interface for fieldset tabs, and there is a new config option to show the original field width alongside the template context field width.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Robin S said:

v0.1.3 adds a tabbed interface for fieldset tabs, and there is a new config option to show the original field width alongside the template context field width.

Thanks @Robin S - I see that adding the tabbed interface was a significant amount of work - I think it's awesome though so thank you 🙂

One small thing - it needs a fallback to tab_name if there is no label set. This should be an unlikely scenario, but without it, you can't get to the other tabs.

            $markup .= "<li class='tfw-tab{$active}' data-tab='tfw-{$tab_name}'>" . ($tab_data['label'] ?: $tab_name) . "</li>";

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, adrian said:

One small thing - it needs a fallback to tab_name if there is no label set.

Thanks, fixed in the latest version.

  • Like 1

Share this post


Link to post
Share on other sites

Great idea and implementation, even though I could live with a mouse dragging - I know it would be a tough task, so it's NOT a feature request 🙂 

I played with it and left-aligning the inputs would disable the "jump" when the width value is changed via mouse (after each click on the number input spinner you have to move the mouse a bit). Also note that the inputs and names are in one line that makes the "editor" more compact.

ftw-left-aligned.thumb.png.51e5a76dbbbc88ea67cdc5ca15eb4629.png

Unfortunately the module is not compatible with aos_column_break, but I don't expect the module to support it as it would be really hard. For example, the corresponding page looks like this with the above template:

pageeditscreen.thumb.png.8226ef1b29c16afe8b8e4bf09f67e4ac.png

In theory it would be not that hard to support the "main" tab but additional aos columns can set inside tabs which would be a nightmare to deal with 🙂

  • Like 2

Share this post


Link to post
Share on other sites
33 minutes ago, tpr said:

I played with it and left-aligning the inputs would disable the "jump" when the width value is changed via mouse

That's a good point, thanks. Have changed to left alignment in v0.1.5.

34 minutes ago, tpr said:

Also note that the inputs and names are in one line that makes the "editor" more compact.

Not sure I want to make this change as if the show original field width config option is enabled it makes the label a bit disconnected from the input, and for longer field names in narrower columns (esp. on narrower screens) it increases the likelihood of the field name not fitting within the column width. Having the field label break to underneath the input wouldn't be great. So I'm thinking the costs aren't worth the benefit of slightly more efficient use of vertical space. But if others would prefer everything on a single line I'm willing to reconsider.

38 minutes ago, tpr said:

In theory it would be not that hard to support the "main" tab but additional aos columns can set inside tabs which would be a nightmare to deal with 🙂

Yeah, not sure I'm up for tackling that, but if you're tinkering around some time and find a solution that would be cool. 🙂

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, Robin S said:

Not sure I want to make this change as if the show original field width config option is enabled it makes the label a bit disconnected from the input, and for longer field names in narrower columns (esp. on narrower screens) it increases the likelihood of the field name not fitting within the column width. Having the field label break to underneath the input wouldn't be great. So I'm thinking the costs aren't worth the benefit of slightly more efficient use of vertical space.

Yep, that's true. How about making this as an option? Most of the time work on templates is done on wide screen. Also, some might prefer to have fieldsets on the main screen, not on separate tabs, so I would make this configurable too. Just an idea, not a feature request.

Share this post


Link to post
Share on other sites

Maybe enabled only on larger screens with @media queries?

Share this post


Link to post
Share on other sites

Thanks for this helper module, it works great. The only issue I see in my case is that the total percentage width of the rows only equals:

2 items per row - 92%.

3 items per row - 86%

Any more than that and the field falls back down. Other than that its awesome, many thanks.

Running v0.1.5 , Processwire 3.0.1.1.8, Firefox browser, wamp on windows 7

Edited by breezer
added more description to the issue

Share this post


Link to post
Share on other sites
4 hours ago, breezer said:

The only issue I see in my case is that the total percentage width of the rows only equals:

2 items per row - 92%.

3 items per row - 86%

Any more than that and the field falls back down.

Sounds like a CSS box-sizing issue. Are you using an unmodified core admin theme? All three core admin themes apply box-sizing: border-box to all elements so I'm puzzled why that wouldn't be working in your case. Maybe you can use your browser dev tools to investigate?

Share this post


Link to post
Share on other sites

My setup is non modified PW dev and uikit admin theme. I basically just edited the existing user template, and moved the role tab last in the sort since it doesn't show during profile edit. Then go to edit my profile to check the fields. All the items are pushed far left and there is a space on the right of the column:

| [ Field One ] [Field Two]     |

| [ Field One ] [ Field Two ] [ Field Three ]     |

What am I looking for when I use the dev tools, css issues are pretty much out of my realm lol

 

Share this post


Link to post
Share on other sites
5 minutes ago, breezer said:

Then go to edit my profile to check the fields. All the items are pushed far left and there is a space on the right of the column

Are we talking about layout issues in the "Field widths" field that TemplateFieldWidths adds to the Edit Template screen...

2018-11-27_103318.png.78732f44e610108b5958e3ba6394f56d.png

...or layout issues when you are editing a page/profile?

2018-11-27_103416.png.63fd709c26e1d5bfb9a7d2e64e2ef5e6.png 

Because TemplateFieldWidths doesn't have anything to do with the latter - the module just adds a quicker way to define field widths. You can check by uninstalling TemplateFieldWidths and seeing if you still have layout issues when editing a page/profile.

If it's the latter problem you could ask a question one of the main support forums, but also check this loooong GitHub issue about column widths in AdminThemeUikit: https://github.com/processwire/processwire-issues/issues/480
Personally I recommend the following config option: Modules > Core > AdminThemeUikit > Layout + interface > Inputfield column widths > Percentage-based widths

Share this post


Link to post
Share on other sites
Quote

Personally I recommend the following config option: Modules > Core > AdminThemeUikit > Layout + interface > Inputfield column widths > Percentage-based widths

Yes that feature is enabled. Here is what I get from the following setup:

fieldwidth_1.jpg.af9c2b0cf628e411f323d0986bbd455c.jpg

fieldwidth_2.jpg.8ccb0db40a69842614a77a51563f9a05.jpg

fieldwidth_3.jpg.fdab8c9daa6797470591c21182be4cf5.jpg

fieldwidth_4.jpg.1381ccfb049bc4e08bb04df2c9a7e92e.jpg

 

Share this post


Link to post
Share on other sites

@breezer, like I said, your issue is not related to this module and you can confirm this by uninstalling TemplateFieldWidths.

But your admin layout looks non-standard - compare with my screenshot above which does not have the grey background or space between inputfields. Maybe this is caused by some non-default option in AdminThemeUikit or you have interference from some non-core CSS somewhere. 

Share this post


Link to post
Share on other sites

I'll uninstall and see what happens, thanks for looking into it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By louisstephens
      I have done a bit of searching, but I can not seem to find an actual answer. I have a list of services as child pages under "Services". I can output the services just fine, but I cant wrap my head around how to group them "alphabetically" like:
      Services A - Service "A" 1 - Service "A" 2 - Service "A" 3 B - Service "B" 1 - Service "B" 2 - Service "B" 3 C - Service "C" 1 - Service "C" 2 - Service "C" 3 Has anyone achieved this type of functionality before?
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot: