pragmaMx Support Forum

pragmaMx => Individuelle Anpassungen => Thema gestartet von: titoun am 06 Februar 2022, 14:48:19

Titel: Modify the type of fields
Beitrag von: titoun am 06 Februar 2022, 14:48:19
Hello and have a nice Sunday  :bye:

I would like to change the type of input fields mxText
$tb->add("","input","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);

for the date and time selection window like that
(https://i.postimg.cc/J0pMTh9Y/1.png)

And if possible change the display 2022-02-06 13:00:00 to this one 06-02-2022 13:00:00

Please help me  :red:
Titel: Re: Modify the type of fields
Beitrag von: Olaf am 06 Februar 2022, 18:12:42
very simple : :drinks:

modify your code
$tb->add("","TYPE","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);

replace TYPE with:
- "date" for Select Date only
- "datetime" for select date and time
- "time" for the time only

included in pragmamx since v2.4  :yltype:

see also the class "Adminform.php" in "includes/classes"

see also: modules/Documents/admin/admin_content.php at line 676ff.
Almost all types are used in Documents....

:bye:
Titel: Re: Modify the type of fields
Beitrag von: titoun am 06 Februar 2022, 20:35:51
Good evening Olaf

On the Module OnePage V1.4 it works and it's very simple  :thumbup:
But it does not work for the pmxslider module that I modified to create my module  :red:

yet I added a new class in the file classe "Adminform.php" which works well  :puzzled:
Maybe a code to add
Titel: Re: Modify the type of fields
Beitrag von: Olaf am 06 Februar 2022, 21:31:39
OK,
:gruebel: without specific information about the code, I can't say anything about it.
Titel: Re: Modify the type of fields
Beitrag von: titoun am 07 Februar 2022, 00:07:30
Hello again Olaf

I adapted my module based on pmxslider  :red:
as an example: ligne 405
pmxSlider/admin/admin.php
if i change
$tb->add("","input","record[title]",$record['title'],mxText("_TITLE"),"",60,255);
for
$tb->add("","datetime","record[title]",$record['title'],mxText("_TITLE"),"",60,255);
(https://i.postimg.cc/vTX5tc3X/2.png)
nothing is happening  :puzzled:

as an example: ligne 211
OnePage/admin/admin.php
if i change
$tb->add("language", "input", "title[" . $value . "]", $title, _TITLE, "");
for
$tb->add("language", "datetime", "title[" . $value . "]", $title, _TITLE, "");
(https://i.postimg.cc/C5wj8jHz/1.png)
it works well the datetime is displayed  :cul:

that's why I think something must be missing in module pmxSlider that I can adapt for my personal module  :JC_highfive:

Thanks for the help Olaf
Titel: Re: Modify the type of fields
Beitrag von: Olaf am 07 Februar 2022, 08:58:35
ok

i found your problem

your field name must be unique. The ID of the field is determined from the field name. The ID is required for JS.
the field name is saved with the "add(..." function. If there are special characters in the field name, they are eliminated to determine the ID.  :note:

So:
fieldname="fieldname" then id="#fieldname"
fieldname="field[name]" then ID="#fieldname"

You must be sure that the ID's are unique.
better like this
fieldname ="fieldname1" then ID = "#fieldname1"
fieldname="field[name]" then ID="#filedname"


what is unimportant for "<FORM>" is important for the "ID".  :puzzled:

try it, it works  :pardon:

ok?
Titel: Re: Modify the type of fields
Beitrag von: titoun am 07 Februar 2022, 09:36:09
Hello  :bye:

Sorry Olaf I do not understand  :red:
can you give me an example with this code
$tb->add("","datetime","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);
Titel: Re: Modify the type of fields
Beitrag von: Olaf am 07 Februar 2022, 09:56:58
Zitat von: titoun am 07 Februar 2022, 09:36:09

$tb->add("","datetime","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);

make sure all field names are unique
The ID, which is important for JS, is generated from the field name.

example:
$tb->add("","input","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);
the result id is "recordfonction"
the next field must have a other feldname !!
$tb->add("","datetime","record[fonction]",$record['fonction'],mxText("_COURSE"));
the result id is "recordfonction" also !!
JS will not work

so
$tb->add("","input","here_is_the_feldname",$record['fonction'],mxText("_COURSE"),"",60,255);
the field name must be unique


$tb->add("","input","record[fonction1]",$record['fonction1'],mxText("_COURSE1"),"",60,255);
$tb->add("","datetime","record[fonction2]",$record['fonction2'],mxText("_COURSE2"));
$tb->add("","datetime","record[fonction3]",$record['fonction3'],mxText("_COURSE3"));

Titel: Re: Modify the type of fields
Beitrag von: titoun am 07 Februar 2022, 13:26:26
I modified
$tb->add("","datetime","record[fonction]",$record['fonction'],mxText("_COURSE"),"",60,255);
for
$tb->add("","datetime","record[fonction]",$record['fonction'],mxText("_COURSE"));

it works  :thumbup:

Thank you Olaf