0

I decided to create a website with joomla 4 by creating a cutom field that generates a numeric code within the field when the user registers on the site. I tried to look in joomla's added fields but I didn't find the possibility to implement the javascript code that automatically generates a 6-digit code with a CH prefix (i.e. CH-123456). I would like to use the additional fields of joomla because these connect not only to the customer profile but also to the administrator home page. do any of you know how to create this field with the possibility of implementing javascript code creating random numbers? if you need more examples I can create screenshots. Thank you.

I tried to create the text field but i don't know how to insert javascript code to create random numbers. Unfortunately I deleted the code.

2 Answers2

0

Use overiding module or component. Then add new input form like

input name = "Look some field from php admin on tabble __users"
typen = "number" value="ch- Rand php from 100000 to 999999"

Why need js instead php to get random code?

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
anatajue
  • 26
  • 5
0

May you look something on search engine how about ovveriding module or component.

DIRECT OVERRIDE | FORBIDDEN FROM JOOMLA

My project is somewhat similar to yours in adding custom field from scrath to form. In com_content, you can follow the step on com_user.

this is a sample form.xml on my component

 <field
    name="catid"
    type="category"
    label="JCATEGORY"
    addfieldprefix="TamanLangit\Component\RichContent\Administrator\Field"
    required="true"
    default=""
    />

The attribut addfieldprefix is a function to get the I/O value. In joomla it defaults to "Joomla\Component\Categories\Administrator\Field". You can find these functions under adm\com\categories\layouts\form" or "layouts\joomla\form\field"

I made a custom layout so my addfieldprefix value is "TamanLangit\Component\RichContent\Administrator\Field" whose function can be found in adm\com\richcontent\layouts\form and the name of the file is on attribut type value="category"

When the addfieldprefix attribute is set, then joomla will search for type="value" (value on the the type attribute) in default joomla layout path "layouts\joomla\form\field"

Disadvantages

all overiding will be gone on update, so i built my own new component to cover all MVC.

But if you can make all in single layout, the update still cannot prevent this. Your new layouts will be exist after update.

------------

CUSTOM FIELD JOOMLA TWEAK

Make some CF joomla default and desired value or form from component on adm. Then login to phpmyadmin at access the CF table. Edit your CF, edit the field context make com_user.

joomla default is com_content.article, my project is com_richcontent.article

Then use source from default com_content.article.template

<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>

on your template registration view.

joomla.edit.params function can be found in "Layouts\Joomla\edit\params.php". You will see all field function over there.

Disadvantages

  1. call CF to user view (this is just simple CRUD) but you need solving the where DB Clause condition.
  2. the nigtmare is update, all overiding to genuine joomla component will be gone.
shaedrich
  • 5,457
  • 3
  • 26
  • 42
anatajue
  • 26
  • 5