Non editable field that clones value from other field in page, realtime

Hello,

Imagine two text-like fields in a panel page. If I write “a string” in the first, the second one shows “a string” aswell, but is not editable. This happens realtime, or once I saved the page.

I guess the first field could be a text field, and the second an info field. But how would I go and link them in such manner ?

Maybe a ‘save’ page panel hook? can that update a field with another field’s content?

The case scenario is that I want to generate say, a password, from a title, instead of telling the user “use the title as password”.

Thank you very much.

Yes, a panel.page.update hook would be the way to go.

Edit: Are we really talking about unencrypted passwords here?

1 Like

@pixelijn thank you

That was next question step, hehe.

Although these would be passwords to relatively trivial content, I was hoping for a way to encrypt them. Since I understand they would be stored in a txt file in the content folder, I guess I wonder if those can be encrypted or there is a workaround.

Thing is the people who will use the panel need to create users for a growing number of entities, possibly hundreds, and also fill some info about each. We were thinking into unifying info and user/pass into a page, and build our own custom frontend login system for the trivial things each needs to have private access to.

While writing I am wondering if perhaps using a db would be a better approach.

Thanks!

Well, of course you could encrypt the password, but honestly, I see very little purpose in encrypting a copy of a plain text string?

Hello @texnixe, do you mean that since the pass is a copy from a plain text title, is futile to encrypt one and not the other. Did I get that right?

I thought it could be possible to generate a pass using the title field and some script. So it is not a copy, Does that make more sense? And how to encrypt then in kirby?

Alternatively, is there a way to auto-generate a passw in a field ?

thanks

Yes, that’s what I meant.

Well, yes, but if you auto-generate an encrypted password, it will not really be useful.

So, yep, as I say I won’t be using an exact copy but build the pass from the title with a script on the panel hook, if that makes sense.

And so how to encrypt ? Does it make sense to encrypt a pass but show it in the panel to the admin?

Also what is the field that generates a pass?

Excuse me if these questions are too newb :sweat_smile: This is something I’ve never done.

Thanks!

Why don’t you use a password field instead? Like in the user pages?

I can’t seem to find such field in the cheatsheet ?

It’s a secret field :wink:, but I just tested it and it doesn’t save an encrypted version of the password, so you would have to create a custom field.

secret field!

Ok, but… why does the user login system of kirby does NOT need/use encryption? (I mean because if Kirby does not need it, why should I)

/edit
If I check site/accounts/myuser.php the password seems to me definitively encrypted, as it shows a long string which is not the actual myuser password?

thanks

Yes, the user account password is encrypted whereas the password field does not encrypt its value, I have no idea why. But you could make your own version of the Password field and add the same encryption that is used in the user password field. But I’m not really sure if this makes sense or not or if it would work…

@texnixe where does the encryption occur then ? I guess you are looking at source, could you point me where, please?

Thank you!

Check out the Password class in kirby/vendor/getkirby/toolkit /lib/password.php

1 Like