how do I set value of hidden fields
how do I set value of hidden fields
ourteamweb
Posts: 3Questions: 1Answers: 0
in Editor
I need to set the value of hidden fields when adding a new record.
The Username field is hidden and should be the same value as the Email field.
The Usergroups field is hidden and will always be "BUILDER".
I can't find any documentation on how to this within the Editor server script
Here is my current code:
Editor::inst( $db, 'members', 'id' )
->fields(
Field::inst( 'Custom1' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'Name' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'Email' )
->validator( 'Validate::email', array( 'empty' => false ) ),
Field::inst( 'Custom2' )
->validator( 'Validate::notEmpty' )
)
->where( 'Usergroups', '%BUILDER%', 'LIKE' )
->process( $_POST )
->json();
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
For the
Usergroups
field use thefields.def
option to set a default value that will always be used.For the Username, use the
preSubmit
event to set the value:Allan
Thanks Allan, that worked for me.
I added this to my js
And I added this to my Editor code:
And I repeated the same process with other hidden fields.